Skip to content

Instantly share code, notes, and snippets.

@loudoweb
Last active March 4, 2024 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loudoweb/6fbded67805c682adef488553b06c2e7 to your computer and use it in GitHub Desktop.
Save loudoweb/6fbded67805c682adef488553b06c2e7 to your computer and use it in GitHub Desktop.
ffmpeg commands
//png sequence with alpha from video
ffmpeg -c:v libvpx -i myvideo.webm %02d.png
//video from png sequence
ffmpeg -framerate 30 -i image%d.png -c:v libx264 -crf 10 -b:v 1M output.mp4
ffmpeg -framerate 30 -i image%d.png -c:v libvpx -crf 10 -b:v 1M output.webm
//video from png sequence with alpha
ffmpeg -framerate 30 -i image%d.png -c:v libvpx-vp9 -pix_fmt yuva420p output.webm
//gif to webm (quality 0 to 60, lower is better)
ffmpeg -i inputfilename.gif -c vp9 -b:v 0 -crf 10 outputfilename.webm
//convert video with same parameters
ffmpeg -i inputfilename.mkv -c:v copy -c:a copy outputfilename.mp4
//remove sound
ffmpeg -i inputfilename.mp4 -c copy -an outputfilename.mp4
//convert video with alpha to hevc (note: adjust 2000k with your bitrate target)
ffmpeg -i myvideo.mov -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -b:v 2000k -vtag hvc1/ output.mov
//convert mp4 with alpha to hevc mov
ffmpeg -i myvideo.mp4 -acodec copy -vcodec copy -f mov output.mov
//mp4 to webm
ffmpeg -i myvideo.mp4 -c:v libvpx-vp9 -crf 15 -b:v 0 -b:a 128k -c:a libopus myvideo.webm
//extract poster from first frame (note: adjust 0.0 to frame needed, here it's the first frame)
ffmpeg -ss 0.0 -i myvideo.webm -frames:v 1 myposter.jpg
//batch loudness normalization of multiple files
// target loudness (I), loudness range (LRA), and true peak level (tp). For speech use speechnorm instead.
@echo off
for %%A in (*.wav) do (
ffmpeg -i "%%A" -af loudnorm=I=-16:LRA=11:tp=-1.5 -ar 44100 "normalized_%%A"
)
//batch convert to mp3
@echo off
for %%A in (*.wav) do (
ffmpeg -i "%%A" -codec:a libmp3lame -qscale:a 2 "%%A.mp3"
)
//extract only a portion of video (-ss start, -t duration)
ffmpeg -ss 5 -t 3 -i source.webm -vf scale=553:-1 -filter:v "setpts=0.5*PTS" output.webm
//accelerate 2x speed
ffmpeg -i source.webm -filter:v "setpts=0.5*PTS" output.webm
//rescale (-1 means keep proportion)
ffmpeg -i source.webm -vf scale=400:-1 -filter:v output.webm
//cut video in 2 parts (-t 00:05:00.000 duration of first video, -ss 00:05:00 start time of second video) not very precise in the duration...
ffmpeg -i input.mp4 -t 00:05:00 -c copy part1.mp4 -ss 00:05:00 -c copy part2.mp4
//convert to apng format (-r fps, -plays 0 means loop, compression [0,100] with 100 most compression)
ffmpeg -i source.webm -f apng -compression_level 100 -r 12 -plays 0 output.png
//convert to gif (-r fps)
ffmpeg -i source.webm -f gif -r 12 output.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment