FFMPEG mkv to mp4 conversion loses subtitles

Solution 1:

MP4 does not support SRT. You can either use softsubs or hardsubs.

softsubs

Subtitles that consist as a separate stream in the file. They can be toggled on/off by the player, and do not require the video stream to be re-encoded.

ffmpeg -i input.mkv -c copy -c:s mov_text output.mp4

Player support for timed text softsubs in MP4 can be rather poor. You'll just have to try it.

hardsubs

Hardsubs are "burned" into the video so the video must be re-encoded.

ffmpeg -i input.mkv -vf subtitles=input.mkv output.mp4

See the susbtitles filter documentation for more info such as how to select a particular subtitle stream if there is more than one.

Solution 2:

I had a similar problem going from MP4 to MKV from some mp4 files I ripped with Handbrake. I first consulted https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/subtitle_options, which implied particular subtitle formats for mkv vs mp4. After playing around with ass and mov_text conversions that didn't work, I tested some files and noticed the dvd_subtitle format appearing. After a lot of playing around the following worked.

ffmpeg -i "\\server\directory\Sourcefile.mp4" -c:v copy -c:a copy -c:s dvd_subtitle "\\server\directory\Outputfile.mkv"

Hope it helps.