VideoHelp Forum




+ Reply to Thread
Results 1 to 2 of 2
  1. Hello all. Long time lurker, first time poster. I've used these forums to learn about and make MKVToolnix batch files for quite some time, so thanks to everybody! I'm looking to tweak/automate my batch files a little bit. I have 100+ MP4s and used the below batch to convert them to MKV:

    Code:
    FOR /R %%I IN (*.mp4) DO (
    	ECHO %%~fI
    	IF EXIST "%%~fI" ( :if an mp4 file exists, convert it
    		echo "%%~I" exists
    		mkvmerge -o "%%~dI%%~pI%%~nI.mkv" "--forced-track" "0:no" 
    "--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" 
    "-a" "1" "-d" "0" "-S" "-T" "--no-global-tags" 
    "--no-chapters" "(" "%%I" ")" "--track-order" "0:0,0:1"
    	)
    )
    It worked great for the MP4s with the video as Track 0 and Audio as Track 1. However, many of the MP4s had the video and audio tracks reversed so it didn't work. I then used the below (with the highlighted changes):

    Code:
    FOR /R %%I IN (*.mp4) DO (
    	ECHO %%~fI
    	IF EXIST "%%~fI" ( :if an mp4 file exists, convert it
    		echo "%%~I" exists
    		mkvmerge -o "%%~dI%%~pI%%~nI.mkv" "--forced-track" "0:no" 
    "--language" "0:eng" "--default-track" "0:yes" "--forced-track" "0:no" 
    "-a" "0" "-d" "1" "-S" "-T" "--no-global-tags" 
    "--no-chapters" "(" "%%I" ")" "--track-order" "0:1,0:0"
    	)
    )
    It worked, but my question is: is there a way to write just one batch file that would auto detect which track ID the audio and video is, and then outputs it so the MKV video is track 0 and the audio is track 1?

    Thanks in advance!
    Quote Quote  
  2. It's probably possible to analyze output of mkvmerge -i "input.mp4" but batch is a bitch so I won't do it.

    A very dirty yet simple way would be to add the input file twice but deactivate audio and video respectively, like this:
    mkvmerge -o output.mkv --no-audio input.mp4 --no-video input.mp4

    Then run a second pass with mkvpropedit for the flags.

    /edit:
    I just realized mkvpropedit pass can be skipped. Just mark both tracks as english in the input section with --no-video for example. The track you aren't keeping does not matter anyways.
    Last edited by sneaker; 11th Jun 2015 at 13:13.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!