Shrink mkv with ffmpeg -- keep all subtitles and foreign language audio tracks

Below is a simple command to shrink an mkv file using ffmpeg -- i.e., convert mkv to mkv -- and keep all existing subtitles and audio tracks (which is NOT ffmpeg's default). You can use this overnight to shrink 25 GB MKV files to around 5 GB or so -- i.e., 80% smaller.

Preview (to test the results):

ffmpeg -nostdin -y -ss 1400 -t 30 -i /some/path/INPUT.mkv -c:s copy -map 0 -crf 24 /some/path/OUTPUT.mkv

Full video:

ffmpeg -nostdin -y -i /some/path/INPUT.mkv -c:s copy -map 0 -crf 24 /some/path/OUTPUT.mkv

Explanation

-ss 1400 = start at 1400 seconds into the video

-t 30 = continue for 30 seconds and then stop

-y = don't prompt to overwrite the output file if it exists

-i = input file

-c:s copy = copy the subtitles AS IS, don't convert them

-map 0 = copy ALL the video, audio, and subtitle tracks that exist

-crf 24 = Constant Rate Factor. Higher values give higher compression. Best values: 18-24

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.