Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

ffmpeg cheatsheet

Docs (ffmpeg manual - Codecs - Filters) - Wiki

Combine files

See https://trac.ffmpeg.org/wiki/Concatenate

Trim to timestamps

To cut a video from 00:11:22 to 00:33:44:

ffmpeg -i INFILE -ss 00:11:22 -to 00:33:44 -c copy outfile

Fix out of phase stereo audio

Use this when a stereo audio track is messed up such that the left and right channels cancel each other out when played in mono. You have to re-encode the audio when you use audio filters, so you'll need to replace CODEC with your codec of choice.

ffmpeg -i INFILE -af "asplit[a],aphasemeter=video=0,ametadata=select:key=lavfi.aphasemeter.phase:value=-0.005:function=less,pan=1c|c0=c0,aresample=async=1:first_pts=0,[a]amix" -c:v copy -c:a CODEC OUTFILE

More info: https://trac.ffmpeg.org/wiki/AudioChannelManipulation

Adjust aspect ratio

Without re-encoding:

ffmpeg -i INFILE -aspect NEWWIDTH:NEWHEIGHT -c copy OUTFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.