Skip to content

Instantly share code, notes, and snippets.

@kurrik
Last active January 8, 2019 15:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kurrik/6dd2cb9c3ce506d397af to your computer and use it in GitHub Desktop.
Save kurrik/6dd2cb9c3ce506d397af to your computer and use it in GitHub Desktop.
ffmpeg recipes
# Convert `mymovie.mp4` to `mymovie.mov`, re-encoding.
ffmpeg -i mymovie.mp4 mymovie.mov
# Change `mymovie.mov` to `mymovie.mp4`, without re-encoding.
ffmpeg -i mymovie.mov -vcodec copy -acodec copy mymovie.mp4
# Change `mymovie.mp4` to `mymovie-nosound.mp4`, dropping audio and re-encoding video to H.264 high quality
ffmpeg -i mymovie.mp4 -c:v libx264 -profile:v high -an mymovie-nosound.mp4
# Resize `mymovie.mp4` to `mymovie-480.mp4`, setting width to 480px and keeping aspect ratio
ffmpeg -i mymovie.mp4 -vf scale=480:-1 mymovie-480.mp4
# Resize and recompress movie
ffmpeg -i mymovie.mp4 -vf scale=480:-1 -c:v libx264 -profile:v high -an mymovie-nosound-480.mp4
# Change frame rate to 30, re-encode
ffmpeg -i mymovie.mov -vcodec libx264 -acodec copy -r 30 -strict -2 -movflags faststart mymovie.mp4
# Take a clip from `mymovie.mkv` from 00:50:22 through 00:52:22
# and output it to `mymovie-clip.mp4`.
# (Order of arguments matters)
ffmpeg -ss 00:50:22 -i mymovie.mkv -c copy -to 00:02:00 mymovie-clip.mp4
# Resize `mymovie.mov` to 480px wide and convert to animated
# gif, using a framerate of 24 and optimize setting of 3.
ffmpeg -i mymovie.mov -vf "scale=480:trunc(ow/a/2)*2" -pix_fmt rgb8 -r 24 -f gif - | gifsicle --optimize=3 > mymovie.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment