Adding subtitle from command line MP4Box

irrational picture irrational · Jan 23, 2012 · Viewed 8.1k times · Source

I am adding a subtitle file to a video using MP4Box. The following command works perfectly from the command line:

c:/GPAC/MP4Box -add c:/test.m4v#audio -add c:/test.m4v#video -add c:/test_en.srt:hdlr=sbtl:lang=en:group=2:layer=-1 -new c:/test2.m4v

However, what I really want to do is to put the command into a .bat file. The following is my command in the batch file:

%1/GPAC/MP4Box -add %2/%3#audio -add %2/%3#video %4 -new %2/%3

As you can see I am trying to pass in "-add c:/test.m4v#video -add c:/test_en.srt:hdlr=sbtl:lang=en:group=2:layer=-1" as the fourth parameter. The reason I want to do this is there may be many subtitles files being added:

"-add c:/test.m4v#video -add c:/test_en.srt:hdlr=sbtl:lang=en:group=2:layer=-1 -add c:/test.m4v#video -add c:/test_ja.srt:hdlr=sbtl:lang=ja:group=2:layer=-1:disabled"

so I don't know ahead of time how many -add commands there need to be so I want to just pass them all in as one parameter. But, mp4box doesn't like this.

I'm not sure if this is a limitation with mp4box or with batch file parameters in general.

Answer

Chris picture Chris · Dec 1, 2013

I know this is an old thread, but for anyone searching in future.

I used the following approach in a batch file, combined with filemenu tools to allow for a simple right-click menu function to initiate the batch process:

for %%a in (*.m4v) do mp4box -add "%%~Na.eng.srt":lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" "%%a"