I''m trying to mux many subtitle languages into the same file (MKV as output) but it's not working. I'm trying the following from a batch file:

FOR /R %%A IN (*.mp4 *.webm) DO mkvmerge -o "%%~nA.mkv" "%%~A" --language 0:eng "%%~nA.en.srt" --language 1:spa "%%~nA.es.srt" --language 2:ger "%%~nA.de.srt" --language 3:por "%%~nA.pt.srt"

What am I doing wrong?

I get the following result:
Error: The file 'video1.en.srt' could not be opened for reading: open file error.

It's reading all the files correctly, but it won't process the command.

  • Are you sure that video1.en.srt does exist in the directory the FOR loop is executed in? Just to make sure... Or maybe it is open in another program without SHARE_READ privileges... – zx485 Jan 15 at 23:27
  • Yes. It does exist but sometimes it doesn't. Sometimes I get es.srt instead of en.srt because some videos are subtitled in English, some in Spanish. Do you that could be a problem? If yes, I will autotranslate all of them to en.srt – G. L. Jan 16 at 0:58
  • 1
    I guess you have to check if a file exists before passing it to mkvmerge. – zx485 Jan 16 at 2:08
  • OK. I'll test today if it will solve the problem. That is, I have a batch to autosub the video in "en.srt". I don't think it's gonna work but I'll try. – G. L. Jan 16 at 10:36

Now my command is working.

zx485 was right. All files must exist in order for it to work. Also, all language flags must be set to zero in order for it to work.

FOR /R %%A IN (*.mp4 *.webm *.avi) DO mkvmerge -o "%%~nA.mkv" "%%~A" --language 0:eng "%%~nA.en.srt" --language 0:spa "%%~nA.es.srt" --language 0:ger "%%~nA.de.srt" --language 0:por "%%~nA.pt.srt"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.