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:
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" "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, 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?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" ) )
Thanks in advance!
+ Reply to Thread
Results 1 to 2 of 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.
Similar Threads
-
Mux Batch convert MKV to MP4 with subtitles in Linux
By coquex in forum Video ConversionReplies: 7Last Post: 17th Jun 2016, 17:47 -
Batch converting FLV to MP4?
By Wischmop in forum Video ConversionReplies: 2Last Post: 8th Jun 2015, 01:54 -
Batch converting FLV to MP4. Please Help
By atredis91 in forum Video ConversionReplies: 6Last Post: 4th May 2015, 08:15 -
Batch converting FLV to MP4. Please Help
By atredis91 in forum Newbie / General discussionsReplies: 1Last Post: 2nd May 2015, 21:49 -
MP4 to MKV Possible Aspect Ratio Distortion using MKVToolnix
By gonwk in forum Newbie / General discussionsReplies: 10Last Post: 8th Jul 2014, 21:19