VideoHelp Forum
+ Reply to Thread
Results 1 to 2 of 2
  1. I have a bunch of anime series in mkv format on my computer where I want to condense the audio and subtitle tracks from multiple videos together and make them have multiple audio and subtitle tracks instead of more separate videos. For example 2 videos, one with English audio and 2 subtitles (one is for titles, signs etc.) and another video with Japanese audio with subtitles that were translated English. Instead of that I want one video with both audio and all subtitle tracks.

    The audio, video and subtitles are all compatible with one another, I guess meaning they can be muxed together no problems since I tried one with mkvmerge and it worked. The English versions have the same filenames with the exception of the episode number. The Japanese version has a different filename than the English version but all the Japanese versions have the same filenames with one another. With each anime series they are usually all the same format. It's not like I'll have an anime series with different video qualities such as aspect ratios, video format, etc. They are usually the same.

    I already found a program that can batch rip everything from the mkv file such as video, audio and subtitles. If anyone's interested in that program it's called mkvcleaver I think. It was pretty handy. I was looking for program that is similar to that but ADDS extra audio and subtitle tracks in bulk. I don't want to re-encode anything. I couldn't find anything however.

    I was using mkvmerger but as I'm sure other people have the same problem, it can only do each video one at a time. In which this program is now very time consuming when you have over 300 videos plus. Not to mention I read that the program creator doesn't ever intend on adding a batch feature due to time constraints.

    I googled on how to make a batch script for this program and came across all kinds of things but most of the time it was for a different process and wouldn't work for me. I found one where some said to just copy the command line from mkvmerge and paste it onto a text document then paste it for as many as there are videos or episodes then change them. As I mentioned, not a good solution for the large volume of videos I have.

    I know absolutely nothing of coding or anything about the details of mkv files and what not. I only got as far as I did from doing extensive googling. So I'll just post a few things I found and some info from mkvmerge

    I came across this a lot

    FOR %%A IN (*.mkv) DO mkvmerge -o "remux-%%~nA.mkv" "%%~A"

    I guess that's what you use to include in a .bat file but I have no idea what it means, what else goes with it or how to use it.

    Also I came across this video

    It's not what I want to do but I saw something in there about not having to worry about renaming so I wanted that to be included in the .bat file.


    "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "C:\\Users\\Guy\\Videos\\Anim\\Anime Newly Combined Audio Video and Subtitles\\[Yousei-raws] Phantom Requiem for the Phantom 01 [BDrip 1920x1080 x264 FLAC] (1).mkv" "--track-name" "0:BDrip by moodperson" "--default-track" "0:yes" "--forced-track" "0:no" "--display-dimensions" "0:1920x1080" "--language" "1:jpn" "--track-name" "1:LPCM -> FLAC" "--default-track" "1:yes" "--forced-track" "1:no" "--language" "2:eng" "--default-track" "2:no" "--forced-track" "2:no" "-a" "1" "-d" "0" "-s" "2" "-T" "--no-global-tags" "--no-chapters" "(" "C:\\Users\\Guy\\Videos\\Anim\\ALREADY WATCHED\\Phantom\\[Yousei-raws] Phantom Requiem for the Phantom [BDrip 1920x1080 x264 FLAC]\\[Yousei-raws] Phantom Requiem for the Phantom 01 [BDrip 1920x1080 x264 FLAC].mkv" ")" "--forced-track" "0:no" "-a" "0" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "C:\\Users\\Guy\\Videos\\Anim\\Anime Subtitles and Audio Extracts\\[Cman21] Phantom ~Requiem for the Phantom~ Ep 01 'Awakening' [Blu-Ray 1080p][DBAFDE5F]_Track01.flac" ")" "--forced-track" "0:no" "-s" "0" "-D" "-A" "-T" "--no-global-tags" "--no-chapters" "(" "C:\\Users\\Guy\\Videos\\Anim\\Anime Subtitles and Audio Extracts\\[Cman21] Phantom ~Requiem for the Phantom~ Ep 01 'Awakening' [Blu-Ray 1080p][DBAFDE5F]_Track03.ass" ")" "--forced-track" "0:no" "-s" "0" "-D" "-A" "-T" "--no-global-tags" "--no-chapters" "(" "C:\\Users\\Guy\\Videos\\Anim\\Anime Subtitles and Audio Extracts\\[Cman21] Phantom ~Requiem for the Phantom~ Ep 01 'Awakening' [Blu-Ray 1080p][DBAFDE5F]_Track04.ass" ")" "--track-order" "0:0,0:1,0:2,1:0,2:0,3:0"

    I'm sorry that this is so long and drawn out but I wasn't sure what else to put or to do. I think this might be too much to ask but can someone help me making a script for all of this? Is it difficult?
    Quote Quote  
  2. I've created a Windows Batch (.bat) file to solve a similar scenario, and I hope others find useful.


    REM // =======================
    REM || Batch Subtitle Muxing
    REM ||       for MKVmerge
    REM || v0.4-20150511 by drudge
    REM \\ =======================
    REM @@ This batch script will scan the provided directory (or current folder)
    REM @@ for video files, attempt to match them with subtitle files,
    REM @@ and mux them using the MKVmerge command line.
    REM	// ---- ---- ---- ----
    REM // full path to mkvmerge.exe
    	SET "muxpath=C:\Program Files\MKVToolNix\mkvmerge.exe"
    REM \\ -- -- -- -- --
    REM // full path to unrar program, make sure to include switches
    	SET "rarpath=C:\Program Files\7-Zip\7z.exe"
    	SET "rarcmd=e"
    REM \\ -- -- -- -- --
    REM // output path (with trailing slash)
    REM ++ leave blank for working directory
    	SET "outputdir="
    REM @@ default: SET "outputdir="
    REM \\ -- -- -- -- --
    REM // prepend text to output filename
    REM ++ REQUIRED if outputdir is left blank
    	SET "fileprefix=subtitled-"
    REM @@ blank: SET "fileprefix="
    REM \\ -- -- -- -- --
    REM \\ ---- ---- ---- ----
    REM -- editing below this line should be done precisely. (here thar be dragons)
    REM ===========================================================================
    REM @@ simple counters
    SET /A "mc=0"
    SET /A "me=0"
    REM @@ default working path
    SET "wp=."
    REM @@ optional working path via argument
    IF EXIST "%~1" SET "wp=%~1"
    REM @@ ready steady go!
    ECHO ===========================================================================
    REM @@ attempt to use custom setting for output path
    IF EXIST "%outputdir%" (
    	REM @@ user has provided output path
    	ECHO == User Setting -- Output to: [%outputdir%]
    ) ELSE (
    	REM @@ no custom setting, check for prefix
    	IF [%fileprefix%]==[] (
    		ECHO @@ ERROR: empty [fileprefix] setting requires [outputdir] to be set
    		SET /A me+=1
    	REM @@ use working path for output
    	SET "outputdir=%wp%\"
    FOR %%H IN ("%wp%") DO (
    	REM @@ because "." doesn't tell us where we are
    	ECHO == Scanning [%%~dpfH\] for video files...
    FOR %%I IN ("%wp%\*.avi",
    REM			"%wp%\*.customVideoExtension",
    			"%wp%\*.mp4") DO (
    	REM @@ found a video file, now check for subtitles
    	CALL:getsubs "%%~I"
    FOR %%J IN ("%wp%\%~n1.idx",
    REM			"%wp%\%~n1.customSubtitleExtension",
    			"%wp%\") DO (
    REM @@ check for paired subtitle files. USF/XML may require this check as well
    	IF %%~xJ==.idx IF EXIST "%wp%\%%~nJ.idx" IF NOT EXIST "%wp%\%%~nJ.sub" (
    		IF EXIST "%wp%\%%~nJ.rar" (
    			ECHO -- [%%~nJ.sub] -- Found potential .rar
    			ECHO | SET /p extdone=">> "
    			"%rarpath%" "%rarcmd%" "%%~dpJ%%~nJ.rar" | FIND "Extracting"
    		) ELSE (
    			ECHO @@ ERROR: [%%~nJ.idx] -- Missing .sub file
    			SET /A me+=1
    REM @@ subtitle found, time to put it all together
    	IF EXIST "%wp%\%%~nJ%%~xJ" CALL:muxit "%%~f1" "%%~xJ"
    REM @@ make sure the destination file doesn't exist first
    IF EXIST "%outputdir%%fileprefix%%~n1%~x1" (
    	ECHO @@ ERROR: [%~n1%~x1] -- Existing output file
    	SET /A me+=1
    REM @@ we've made it!
    SET /A mc+=1
    REM @@ now we let mkvmerge work its magic
    ECHO | SET /p muxdone="++ Muxing: (%mc%) [%~n1%~x1]"
    "%muxpath%" -q -o "%outputdir%%fileprefix%%~n1%~x1" "%~1" "%wp%\%~n1%~2"
    ECHO  ..complete
    REM @@ success!
    ECHO == Finished Processing: %mc% completed / %me% errors
    ECHO ===========================================================================
    REM @@ game over, man
    Quote Quote