Skip to content

Instantly share code, notes, and snippets.

@seaque
Last active March 2, 2023 11:02
Show Gist options
  • Save seaque/7d9a2ffdee7efb8831ef16c4ef059165 to your computer and use it in GitHub Desktop.
Save seaque/7d9a2ffdee7efb8831ef16c4ef059165 to your computer and use it in GitHub Desktop.
various ffmpeg commands.

Video

Trim

ffmpeg -i in.mp4 -ss 0:00 -to 0:00 -codec copy out.mp4

Upscale to 4K

ffmpeg -i input.mp4 -vf scale=3840x2560:flags=lanczos -c:v libx264 -preset slow -crf 19 output.mp4

Generate Frames

ffmpeg -i input.mp4 -vsync 0 -f image2 frames/frame-%03d.png

H264 render all mp4 files in directory

for %i in (*.mp4) do ffmpeg -i "%i" -c:v libx264 -crf 25 "output\%~ni.mp4"

Reposition timestamp

ffmpeg -i input.mp4 -vf setpts=N/FRAME_RATE/TB -ss 0:00 -to 0:00 -codec copy out.mp4

Audio

Increase Volume

ffmpeg -i ac.mp4 -af volume=6 -vcodec copy ac2.mp4

Downmix 5.1 to Stereo

ffmpeg -i input.mp4 -c:v copy -c:a dca -strict -2 -af volume=1.66 -af "pan=stereo|c0=0.5*c2+0.707*c0+0.707*c4+0.5*c3|c1=0.5*c2+0.707*c1+0.707*c5+0.5*c3" output.mp4

Subtitles

Extract

ffmpeg -i movie.mkv -map 0:s:0 subs.srt

Burn

ffmpeg -i video -i subtitles -c copy -c:s copy output.mkv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment