Currently trying to convert my mkv library to mp4 (Iphone 6 plus)

I've managed to get to mkv to mp4 conversion correctly, but I'm missing the subtitles part (SRT)

Here's my code:

dir/b/s *.mkv >mkvlist.txt   ///////// this gets a list of all the mkv files on the directory

for /F "delims=;" %%F in (mkvlist.txt) do ffmpeg.exe  -i "%%F" -format mp4 -vcodec copy -acodec aac -strict -2 -sn "%%~dF%%~pF%%~nF.mp4"   ///////////// this makes the conversion

del mkvlist.txt     ////// this deletes the txt file

I would like to include subtitles into the scrip, but I´m having trouble inserting the correct name for the subtitles into the script (since this is a multiple conversion batch).

  • .mkv files are a container format. Its very likely that the mkv file contains an .srt file that you can extract. Make sure it has the same name as the .mp4 file and it should work. The mkv file might actually also contain an mp4 file but can also have an .divx, .avi or any other video format.
    – LPChip
    Jun 25, 2015 at 19:31

3 Answers 3


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


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 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.

  • Could you help me better understand my code? Where and why would you add the re-encoding for the subs? (And if you can think of a solution or way to batch convert all the files in the subfolders with their corresponding subs?) (if there are no subtitles, then it would need to skip the file altogether and move on to the next one.
    – dpkmon
    Jun 27, 2015 at 3:00

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.


I hope this can help you in automating the process. This code converts .mp4 video and .srt subtitles files to .mkv file with embedded subtitles.

Batch file.

Just drop 2 files on it at the same time - .mp4 and .srt to get a .mkv video with embedded subtitles.

If you want the original/low video quality, just comment/uncomment the appropriate line in the code.

Among all other things, I made an asynchronous call of msgBox. Who needs it - copy it to your sources.

For some reason, it doesn't accept parentheses () in file names. I did not check the rest of the characters.

    @echo off
    if "%~x1"==".mp4" (
        set mp4=%~n1
        set path=%~d1%~p1
    if "%~x2"==".mp4" (
        set mp4=%~n2
        set path=%~d1%~p1
    if "%~x1"==".srt" set srt=%~1
    if "%~x2"==".srt" set srt=%~2
    if not "%mp4%"=="" (
        if not "%srt%"=="" (
            :: If your original ffmpeg.exe file located in system32 directory then replace "%~dp0ffmpeg.exe" to ffmpeg
            :: original quality
            ::"%~dp0ffmpeg.exe" -i "%path%%mp4%.mp4" -i "%srt%" -ar 48000 -vcodec libx264 -disposition:s:0 default -scodec copy "%path%%mp4%.mkv"
            :: low quality
            "%~dp0ffmpeg.exe" -i "%path%%mp4%.mp4" -i "%srt%" -ar 48000 -ab 128k -ac 2 -vcodec libx264 -s 480x240 -b 256k -disposition:s:0 default -scodec copy "%path%%mp4%.mkv"
            call :msgbox "File %path%%mp4%.mkv completed."
        ) else call :msgbox "File .srt missing in the input parameters`r`nJust drop 2 files with extensions:`r`n.mp4 - video and .srt - subtitles`r`nto this batch file to get .mkv with subtitles"
    ) else call :msgbox "File .mp4 missing in the input parameters`r`nJust drop 2 files with extensions:`r`n.mp4 - video and .srt - subtitles`r`nto this batch file to get .mkv with subtitles"
    goto :eof
    :msgBox [msgText]
    C:\Windows\System32\mshta.exe vbscript:Execute("CreateObject(""WScript.Shell"").Run ""powershell -Command """"[Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')|Out-Null;"""" """"[System.Windows.Forms.MessageBox]::Show(\""""%~1\"""")"""""",0,false:close")
    exit /B

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .