The Matroska Multimedia Container or MKV is a free open container format that differs from formats like MOV or MP4. MKV files can store an unlimited amount of video, audio, pictures or subtitle tracks in one file. This stacking of media has benefits for videos that require audio or subtitles with multiple languages.
Because of the nature of MKV, converting to MP4 requires a few arguments, as seen in the example below:
$ ffmpeg -i input.mkv -c:a copy -c:v libx264 output.mp4
In this example, the command must specify that the audio codec is copied but the video must be encoded with libx264.
If a specific audio track is required for conversion, the command requires mapping the specific audio to the output. For example, if the MKV has two audio tracks and the second track is required for the output, the command is as follows:
$ ffmpeg -i input.mkv -map 0:v -map 0:a:1 output.mp4
Tip: Instagram and Twitter do not support MKV video uploads.
Love FFmpeg? Grab a copy of FFmpeg For Beginners on Kindle or Paperback to learn over 120 ways to master FFmpeg!