Skip to content

Instantly share code, notes, and snippets.

@oxguy3
Last active April 30, 2020 08:29
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 oxguy3/ec9139985ba0ac8d23d2ae7caed486cc to your computer and use it in GitHub Desktop.
Save oxguy3/ec9139985ba0ac8d23d2ae7caed486cc to your computer and use it in GitHub Desktop.

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