How to convert MKV videos to lossless MP4 videos that are compatible with iOS devices on Windows

ffmpeglosslessmatroska

I’m new to FFmpeg (Windows), and need some help.

I want to convert my MKVs to MP4 with as little loss in quality as possible. The MKVs are made with MakeMKV and contain among others DTS soundtrack. They are lossless. The reason I want to convert, is that I plan to stream it to iPads and Apple TV. iPads don’t support DTS and MKVs. The MKVs are both DVDs and Blu-Ray. The MKVs contain video, soundtracks and subtitles.

I have tried this, but get no sound due to DTS soundtrack:

ffmpeg -i input.mkv -c:v copy -c:a copy output.mp4

Can anybody help me?

What codecs should I use? MP4 is the best for Apple?

Best Answer

MP4 is indeed the best format for Apple devices and software. DTS is also indeed not supported, many MP4 video files contain two audio tracks, one DTS and one AAC.

There are multiple encoders available, all of them documented on the ffmpeg wiki. Which codec is available depends on how ffmpeg was compiled. libfdk_aac will give you the best results, but due to this codec being non-free it's not always available.

Things you can try (I put them in the order of my perceived quality, best first)

ffmpeg -i input.mkv -c:v copy -c:a libfdk_aac -b:a 128k output.mp4
ffmpeg -i input.mkv -strict experimental -c:v copy -c:a aac -b:a 192k output.mp4
ffmpeg -i input.mkv -c:v copy -c:a libfaac -b:a 192k output.mp4

If you want to retain the DTS track too, use the -map flag.

Not directly of use for OP, but the OS X program subler makes this process very easy.

EDIT: Comments tl;dr? OP solved problem with the following command

ffmpeg -i input.mkv -strict experimental -map 0:0 -map 0:1 -map 0:2 -map 0:3 -c:v copy -c:a aac -b:a 384 -c:s copy output.mp4

TIP: if -c:s copy for subtitles doesn't work, try -c:s mov_text.
Saved me on multiple occasions.

Related Question