Skip to content

Instantly share code, notes, and snippets.

@amercier
Last active November 8, 2018 06:58
Show Gist options
  • Save amercier/4e49dc02a624376c0a1224317212275b to your computer and use it in GitHub Desktop.
Save amercier/4e49dc02a624376c0a1224317212275b to your computer and use it in GitHub Desktop.

FFmpeg Cheat Sheet

Re-encode a movie

Re-encode video while preserving audio, subtitles, chapters, etc.

Regular movie

ffmpeg -i input.mkv -map 0 -c:a copy -c:s copy -c:v libx264 -preset slow -tune film output.mkv

Animation movie

ffmpeg -i input.mkv -map 0 -c:a copy -c:s copy -c:v libx264 -preset slow -tune animation output.mkv

Others -tune options

  • grain: preserves the grain structure in old, grainy film material
  • stillimage: good for slideshow-like content
  • fastdecode: allows faster decoding by disabling certain filters
  • zerolatency: good for fast encoding and low-latency streaming

Read Encode/H.264 for more details.

Copy all tracks

ffmpeg -i input.mkv -map 0 -c copy output.mkv

Without audio

ffmpeg -i input.mkv -map 0 -c copy -an output-no-audio.mkv

Without video

ffmpeg -i input.mkv -map 0 -c copy -vn output-no-video.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment