Most MKVs contain a h.264 video track, some kind of audio track (usually AAC or AC3) and possibly some subtitles. iOS devices can usually support these but they can’t support the MKV container. A container is simply an envelope in which video, audio and other tracks are stored.
iOS can, however, support the MP4 container. So, it should be a simple matter to take them out of one envelope and put them into another. You can use ffmpeg to do this. This isn’t a guide to how to install ffmpeg, I assume you already have it installed and can access it from the command line.
A simple command to do this:
ffmpeg -i yourinputfile.mkv -c:v copy -movflags +faststart -strict experimental -c:a aac -ac 2 -ab 256K youroutputfile.mp4
To break down what this does:
- -i inputfile.mkv tells ffmpeg to use your MKV file as an input source.
- -c:v copy tells ffmpeg to copy the first video track it finds to the output file without modifying it.
- -movflags +faststart is not strictly necessary but moves some data to the start of the file which makes it start faster when streamed over a network.
- -strict experimental tells ffmpeg to use experimental codecs that would normally be disabled. This is necessary because ffmpeg’s AAC encoder is not classified as ‘done’ yet.
- -c:a aac -ac 2 -ab 256K specifies the parameters for encoding the audio. In this case, we’re using the AAC audio encoder to create a two channel (i.e. stereo) track with an average 256Kbps bitrate. If your input file has an AC3 track (otherwise known as Dolby Digital 5.1) this will downmix that track to stereo. iOS only supports stereo audio playback.
- youroutputfile.mp4 – the name of your output file.
This will take around a minute, depending on the speed of your computer. Unlike using Handbrake or one of the many other tools available on the Internet for this, there is no need to alter the video which drastically cuts down the time it takes to prepare the final file.