Skip to content

Instantly share code, notes, and snippets.

@Da-Juan
Last active July 30, 2018 10:53
Show Gist options
  • Save Da-Juan/d05cce5f5dc91a91d99f80ec0576a96c to your computer and use it in GitHub Desktop.
Save Da-Juan/d05cce5f5dc91a91d99f80ec0576a96c to your computer and use it in GitHub Desktop.

ffmpeg cheat sheet

Re-encode mkv to h264 keeping audio and subtitles tracks

ffmpeg -i input.mkv -map 0:1 -map 0:a -map 0:s -c:a copy -c:s copy -c:v libx264 output.mkv

Explanations:

  • -map 0:1 select first video stream
  • -map 0:a select all audio tracks
  • -map 0:s select all subtitles tracks
  • -c:a copy -c:s copy copy audio and subtitles tracks
  • -c:v libx264 encode video stream to h624

Put 3 GIFs side by side and save the result as a video

ffmpeg -ignore_loop 0 -i 1.gif -ignore_loop 0 -i 2.gif -ignore_loop 0 -i 3.gif -filter_complex "[0:v]hstack=inputs=3[v];[v]scale=w=576:h=72" -t 10 out.mp4

Explanations:

  • -ignore_loop 0do not ignore GIF loop informations
  • -filter_complex "[0:v]hstack=inputs=3[v];[v]scale=w=576:h=72"
    • [0:v]select the video stream
    • hstack=inputs=3 stack horizontally 3 input streams
    • [v] name the resulting stream v
    • [v]scale=w=576:h=72 select the stream named vand scale it to 576x72 pixels
    • -t 10 encode 10 seconds of the output stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment