Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > New and alternative a/v containers
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th August 2014, 05:13   #1  |  Link
Chakabear13
Registered User
 
Join Date: Mar 2011
Posts: 5
batch remux with Mkvmerge

hello, I hope somebody can help me. Currently I have about 70 mkvs. 25 of them I remuxed already. that leaves me with the rest of the videos to remux.

this is the process I did
> open Mkvmerge> add .mkv file> uncheck current sub(s)> add edited .srt (name: ...track02)> change language of that srt to "english">highlight edited .srt and click "up" to move it above chapter track> add to queue or start muxing.

before this process. I removed all subs using Mkvextract then check & correct any errors.

I was reading here and found that you can use batch file to automate this process. Unfortunately I have no clue on how to make a batch file.

thank you
Chakabear13 is offline   Reply With Quote
Old 26th August 2014, 08:01   #2  |  Link
Chetwood
Registered User
 
Chetwood's Avatar
 
Join Date: Nov 2001
Posts: 1,104
  • open the mkv you want to remux in MKVToolnix and apply your settings (remove sub, add srt, set to English...)

  • select muxing > Copy command line to clipboard

  • create the file remux.bat in the folder where your mkvs reside

  • paste the contents of the clipboard into the file

  • add the blue text "if exist..." before and the closing ) after that text

  • change the path of mkvmerge to where you've installed it

  • the -S will remove subs already present in the mkv

  • change all paths to the placeholders marked red:

    • "m:\remux\%%a" <- the remuxed files will be written to m:\remux

    • "%%a" <- this means all mkvs in the input folder where the remux.bat is started from

    • "%%~na.srt" <- the srt you want to add (should be in the folder with the mkvs having the same name)

  • open a command window in the source dir

  • type remux [ENTER]

if exist *.mkv mkdir m:\remux
for %%a in (*.mkv) do (
"D:\Programme\MKVtoolnix\mkvmerge.exe" -S -o "m:\remux\%%a" "--language" "0:eng" "--default-track" "0:no" "--forced-track" "0:no" "--display-dimensions" "0:1280x720" "--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" "-a" "1" "-d" "0" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "%%a" ")" "--language" "0:eng" "--default-track" "0:no" "--forced-track" "0:no" "-s" "0" "-D" "-A" "-T" "--no-global-tags" "--no-chapters" "(" "%%~na.srt" ")" "--track-order" "0:0,0:1,1:0" "--title" "" "--engage" "no_cue_duration" "--engage" "no_cue_relative_position" "--disable-track-statistics-tags"
)


If you pasted everything right, you'll see mkvmerge start. If not, you can read the error message.
__________________

MultiMakeMKV: MakeMKV batch processing (Win)
MultiShrink
: DVD Shrink batch processing
Offizieller Übersetzer von DVD Shrink deutsch

Last edited by Chetwood; 26th August 2014 at 08:17.
Chetwood is offline   Reply With Quote
Old 26th August 2014, 10:44   #3  |  Link
Chakabear13
Registered User
 
Join Date: Mar 2011
Posts: 5
I think I lost you in the last steps.

This is the result after following your instructions.

if exist *.mkv mkdir m:\remux for %%a in (*.mkv) do ("C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -S -o "m:\remux\%%a" "--language" "0:eng" "--default-track" "0:yes" "--forced-track" "0:no" "--display-dimensions" "0:984x720" "--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" "-a" "1" "-d" "0" "-S" "-T" "--no-global-tags" "(" "%%a" ")" "--language" "0:eng" "--forced-track" "0:no" "-s" "0" "-D" "-A" "-T" "--no-global-tags" "--no-chapters" "(" "%%~na.srt" ")" "--track-order" "0:0,0:1,1:0" )


Below is the original lines that I copied from mkvmerge.

"C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "C:\\Users\\Mark\\Desktop\\Movies\\The Mummy (1932) 720p\\The Mummy (1932) 720p (1).mkv" "--language" "0:eng" "--default-track" "0:yes" "--forced-track" "0:no" "--display-dimensions" "0:984x720" "--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" "-a" "1" "-d" "0" "-S" "-T" "--no-global-tags" "(" "C:\\Users\\Mark\\Desktop\\Movies\\The Mummy (1932) 720p\\The Mummy (1932) 720p.mkv" ")" "--language" "0:eng" "--forced-track" "0:no" "-s" "0" "-D" "-A" "-T" "--no-global-tags" "--no-chapters" "(" "C:\\Users\\Mark\\Desktop\\Movies\\The Mummy (1932) 720p\\The Mummy (1932) 720p_Track02.srt" ")" "--track-order" "0:0,0:1,1:0"


Questions:
1.
You said
"%%~na.srt" <- the srt you want to add (should be in the folder with the mkvs having the same name)

My subs don't have the same name with the movies but they are on the same location. However, all of them have "track02" at the end (ex.The Mummy (1932) 720p_Track02). Is there any way to do it with that name?

2.
"open a command window in the source dir" > Im not really sure how to do this. Im using windows 8. are you referring to command prompt?


3.
You also mention that "the remuxed files will be written to "\m:remux" > will this be the same as the directory of the orginal .mkv file?


Please excuse my ignorance. I'm totally noob with regards to codes & technical terms. I appreciate you helping me.
Chakabear13 is offline   Reply With Quote
Old 26th August 2014, 13:32   #4  |  Link
Chetwood
Registered User
 
Chetwood's Avatar
 
Join Date: Nov 2001
Posts: 1,104
1. Should look like this

The Mummy (1932) 720p.mkv
The Mummy (1932) 720p.srt

If it's

The Mummy (1932) 720p.mkv
The Mummy (1932) 720p_Track02.srt

the batch entry would have to read

"%%~na_Track02.srt"

The base name has to be identical, otherwise the batch wouldn't mux the corresponding srt to the right mkv.

2.
Yes. It's called command prompt here or something.

3.
Nope, otherwise you would overwrite the old file and the batch would abort cause it does not add the (1) to the file name. Simply have all mkvs and srts in one dir and use any other dir as the target directory, in my case m:\remux (which usually is on another hdd so the process is faster).

Also, make sure the for %%a starts on a new line in the batch.
__________________

MultiMakeMKV: MakeMKV batch processing (Win)
MultiShrink
: DVD Shrink batch processing
Offizieller Übersetzer von DVD Shrink deutsch
Chetwood is offline   Reply With Quote
Old 26th August 2014, 21:30   #5  |  Link
Chakabear13
Registered User
 
Join Date: Mar 2011
Posts: 5
Still having trouble. I cant figured out how to do this "open a command window in the source dir". The only way I know to open cmd is to go to start>run>type "CMD">enter. So, I just double-click on the batch file that I made. command prompt opens but not mkvmerge & here is the error message in cmd.


I:\TEST\Movies>if exist *.mkv mkdir I:\Test\Movies
A subdirectory or file I:\Test\Movies already exists.

I:\TEST\Movies>for %a in (*.mkv) do ("C:\Program Files (x86)\MKVToolNix\mkvmerge
.exe" -S -o "I:\Remuxed movies\%a" "--language" "0:eng" "--default-track" "0:no"
"--forced-track" "0:no" "--display-dimensions" "0:1280x720" "--language" "1:eng
" "--default-track" "1:yes" "--forced-track" "1:no" "-a" "1" "-d" "0" "-S" "-T"
"--no-global-tags" "--no-chapters" "(" "%a" ")" "--language" "0:eng" "--default-
track" "0:no" "--forced-track" "0:no" "-s" "0" "-D" "-A" "-T" "--no-global-tags"
"--no-chapters" "(" "%~na_Track02.srt" ")" "--track-order" "0:0,0:1,1:0" "--tit
le" "" "--engage" "no_cue_duration" "--engage" "no_cue_relative_position" "--dis
able-track-statistics-tags" )

I:\TEST\Movies>("C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -S -o "I:\Remux
ed movies\The Man with the Golden Gun (1974) 720p.mkv" "--language" "0:eng" "--d
efault-track" "0:no" "--forced-track" "0:no" "--display-dimensions" "0:1280x720"
"--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" "-a" "1"
"-d" "0" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "The Man with the Gol
den Gun (1974) 720p.mkv" ")" "--language" "0:eng" "--default-track" "0:no" "--fo
rced-track" "0:no" "-s" "0" "-D" "-A" "-T" "--no-global-tags" "--no-chapters" "(
" "The Man with the Golden Gun (1974) 720p_Track02.srt" ")" "--track-order" "0:0
,0:1,1:0" "--title" "" "--engage" "no_cue_duration" "--engage" "no_cue_relative_
position" "--disable-track-statistics-tags" )
mkvmerge v7.1.0 ('Good Love') 64bit built on Jul 27 2014 13:06:55
'The Man with the Golden Gun (1974) 720p.mkv': Using the demultiplexer for the f
ormat 'Matroska'.
'The Man with the Golden Gun (1974) 720p_Track02.srt': Using the demultiplexer f
or the format 'SRT subtitles'.
'The Man with the Golden Gun (1974) 720p.mkv' track 0: Using the output module f
or the format 'AVC/h.264'.
'The Man with the Golden Gun (1974) 720p.mkv' track 1: Using the output module f
or the format 'AC3'.
'The Man with the Golden Gun (1974) 720p_Track02.srt' track 0: Using the output
module for the format 'text subtitles'.
The file 'I:\Remuxed movies\The Man with the Golden Gun (1974) 720p.mkv' has bee
n opened for writing.
The Man with the Golden Gun (1974) 720p.mkv: Error in the Matroska file structur
e at position 3114853559. Resyncing to the next level 1 element.
The last timecode processed before the error was encountered was 02:05:11.072000
000.
Resync failed: no valid Matroska level 1 element found.
Progress: 100%
The cue entries (the index) are being written...
Muxing took 31 seconds.






Just wanna clarify some things.

if exist *.mkv mkdir m:\remux for %%a in (*.mkv) do
> the "m:\remux" is the path where my mkv's and srt's?

1.Lets say I have my movies on Drive I>TEST>Movies then I should enter "I:\TEST\Movies" ?


&


"m:\remux\%%a" <- the remuxed files will be written to m:\remux

2. Is this my target folder?
I put "I:\remuxed movies\%%a" ?



I'm I missing something?

if exist *.mkv mkdir I:\TEST\Movies
for %%a in (*.mkv) do
("C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -S -o "I:\Remuxed movies\%%a" "--language" "0:eng" "--default-track" "0:no" "--forced-track" "0:no" "--display-dimensions" "0:1280x720" "--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" "-a" "1" "-d" "0" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "%%a" ")" "--language" "0:eng" "--default-track" "0:no" "--forced-track" "0:no" "-s" "0" "-D" "-A" "-T" "--no-global-tags" "--no-chapters" "(" "%%~na_Track02.srt" ")" "--track-order" "0:0,0:1,1:0" "--title" "" "--engage" "no_cue_duration" "--engage" "no_cue_relative_position" "--disable-track-statistics-tags"
)



***EDIT***
I tried manually using mkvmerge without .bat to remux the file & I got the same result. The problem is there was no muxed mkv when I used the batch. Below is the output in mkvmerge.

mkvmerge v7.1.0 ('Good Love') 64bit built on Jul 27 2014 13:06:55
'I:\TEST\Movies\The Man with the Golden Gun (1974) 720p.mkv': Using the demultiplexer for the format 'Matroska'.
'I:\TEST\Movies\The Man with the Golden Gun (1974) 720p_Track02.srt': Using the demultiplexer for the format 'SRT subtitles'.
'I:\TEST\Movies\The Man with the Golden Gun (1974) 720p.mkv' track 0: Using the output module for the format 'AVC/h.264'.
'I:\TEST\Movies\The Man with the Golden Gun (1974) 720p.mkv' track 1: Using the output module for the format 'AC3'.
'I:\TEST\Movies\The Man with the Golden Gun (1974) 720p_Track02.srt' track 0: Using the output module for the format 'text subtitles'.
The file 'I:\TEST\Movies\The Man with the Golden Gun (1974) 720p (1).mkv' has been opened for writing.
I:\TEST\Movies\The Man with the Golden Gun (1974) 720p.mkv: Error in the Matroska file structure at position 3114853559. Resyncing to the next level 1 element.
The last timecode processed before the error was encountered was 02:05:11.072000000.
Resync failed: no valid Matroska level 1 element found.
The cue entries (the index) are being written...
Muxing took 43 seconds.

Last edited by Chakabear13; 26th August 2014 at 22:14. Reason: addendum
Chakabear13 is offline   Reply With Quote
Old 26th August 2014, 22:39   #6  |  Link
foxyshadis
Angel of Night
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
Looks like an error in your movie, you'll likely have to go back and re-encode it.
foxyshadis is offline   Reply With Quote
Old 26th August 2014, 22:49   #7  |  Link
Chakabear13
Registered User
 
Join Date: Mar 2011
Posts: 5
Finally GOT it! I was looking at the wrong folder.
A few hiccups though.

1. After remuxed "Chapter" tracks are gone. How can I keep the chapter track and only remove current subtitle(s)?

2. New subtitle file is not labeled "Default or Yes" in Default Track Flag.


3. Is there any way to tell if there is really an error muxing the files with this process?
I'm not very familiar looking at cmd so if I remuxed 50+ mkvs I wont be able to tell easily w/c one has error that needs to be fixed. (When I remuxed my first 25 mkvs. I got errors on some of them in mkvmerge).

4. If my mkv file has foreign audio will this batch change it to english?

Last edited by Chakabear13; 26th August 2014 at 23:06.
Chakabear13 is offline   Reply With Quote
Old 27th August 2014, 08:00   #8  |  Link
Chetwood
Registered User
 
Chetwood's Avatar
 
Join Date: Nov 2001
Posts: 1,104
Quote:
Originally Posted by Chakabear13 View Post
Finally GOT it! I was looking at the wrong folder.
Probably because you used I:\TEST\Movies and I:\Remuxed movies\. The first line of the batch creates the target directory. It only does it so Mkvmerge does not abort when the dir is not present. Thus, it must be the same dir.

Quote:
Originally Posted by Chakabear13 View Post
A few hiccups though.

1. After remuxed "Chapter" tracks are gone. How can I keep the chapter track and only remove current subtitle(s)?

2. New subtitle file is not labeled "Default or Yes" in Default Track Flag.

3. Is there any way to tell if there is really an error muxing the files with this process?
I'm not very familiar looking at cmd so if I remuxed 50+ mkvs I wont be able to tell easily w/c one has error that needs to be fixed. (When I remuxed my first 25 mkvs. I got errors on some of them in mkvmerge).

4. If my mkv file has foreign audio will this batch change it to english?
The idea is to use ALL settings you need on a demo file in MKVToolnix: set subtitle to default yes if you want to play it back automatically, label the foreign audio to French or whatever. Only then copy the command-line to the clipboard and paste it into the batch where all you need to do is to replace the three instances where actual filenames are used.

Since we're talking batches here, the composition of the files needs to be identical! You cannot have one mkv where the subtitle is set to default yes and another where the subtitle is set to default no. Dunno why mmg copied this over but if you browse the command carefully, you'll notice "--no-chapters". Remove this and the chapters are muxed too.
__________________

MultiMakeMKV: MakeMKV batch processing (Win)
MultiShrink
: DVD Shrink batch processing
Offizieller Übersetzer von DVD Shrink deutsch

Last edited by Chetwood; 27th August 2014 at 10:33.
Chetwood is offline   Reply With Quote
Old 27th August 2014, 22:47   #9  |  Link
Chakabear13
Registered User
 
Join Date: Mar 2011
Posts: 5
Quote:
Originally Posted by Chetwood View Post
Probably because you used I:\TEST\Movies and I:\Remuxed movies\. The first line of the batch creates the target directory. It only does it so Mkvmerge does not abort when the dir is not present. Thus, it must be the same dir.


The idea is to use ALL settings you need on a demo file in MKVToolnix: set subtitle to default yes if you want to play it back automatically, label the foreign audio to French or whatever. Only then copy the command-line to the clipboard and paste it into the batch where all you need to do is to replace the three instances where actual filenames are used.

Since we're talking batches here, the composition of the files needs to be identical! You cannot have one mkv where the subtitle is set to default yes and another where the subtitle is set to default no. Dunno why mmg copied this over but if you browse the command carefully, you'll notice "--no-chapters". Remove this and the chapters are muxed too.

That worked! thanks again. This will save me a lot of time.
Chakabear13 is offline   Reply With Quote
Old 29th August 2014, 04:38   #10  |  Link
fryk
Member
 
fryk's Avatar
 
Join Date: Aug 2012
Posts: 18
My short suggestion:
Code:
:: lets go
@ECHO OFF &SETLOCAL disableDelayedExpansion
md output 2>nul
for %%a in (*.mkv) do mkvmerge -o "output\%%~a" -S "%%~a" --language eng "%%~na.track02.srt"
https://www.bunkus.org/videotools/mk.../mkvmerge.html
fryk is offline   Reply With Quote
Old 29th August 2014, 06:10   #11  |  Link
Chetwood
Registered User
 
Chetwood's Avatar
 
Join Date: Nov 2001
Posts: 1,104
Right, known resource but since he mentioned subs I thought it'd be better to offer setting defaults and stuff as well.
__________________

MultiMakeMKV: MakeMKV batch processing (Win)
MultiShrink
: DVD Shrink batch processing
Offizieller Übersetzer von DVD Shrink deutsch
Chetwood is offline   Reply With Quote
Old 29th August 2014, 07:56   #12  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
@fryk
You forgot to supply a TrackID for the --language parameter:
Code:
for %%a in (*.mkv) do mkvmerge -o "output\%%~a" -S "%%~a" --language 0:eng "%%~na.track02.srt"
sneaker_ger is offline   Reply With Quote
Old 29th August 2014, 13:55   #13  |  Link
Thunderbolt8
Registered User
 
Join Date: Sep 2006
Posts: 2,197
can I create a batch file as well when I want to mux video + audio + subs for a TV series so that I wont have to do all the clicking for all the episodes of a season separately? does anyone know how I could do that?

the file names are all similar in such a case, only difference would be the S0XE0X season/episode part of the name.
__________________
Laptop Lenovo Legion 5 17IMH05: i5-10300H, 16 GB Ram, NVIDIA GTX 1650 Ti (+ Intel UHD 630), Windows 10 x64, madVR (x64), MPC-HC (x64), LAV Filter (x64), XySubfilter (x64) (K-lite codec pack)
Thunderbolt8 is offline   Reply With Quote
Old 29th August 2014, 14:00   #14  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
"similar" is not a sufficient description. Post the exact names of a few files as an example others can work with.
sneaker_ger is offline   Reply With Quote
Old 29th August 2014, 15:48   #15  |  Link
Thunderbolt8
Registered User
 
Join Date: Sep 2006
Posts: 2,197
actually it is.

example: blablaS01E01.mkv blablaS01E01.dtsma blablaS01E01.ass blablaS01E02.mkv blablaS01E02.dtsma blablaS01E02.ass...
__________________
Laptop Lenovo Legion 5 17IMH05: i5-10300H, 16 GB Ram, NVIDIA GTX 1650 Ti (+ Intel UHD 630), Windows 10 x64, madVR (x64), MPC-HC (x64), LAV Filter (x64), XySubfilter (x64) (K-lite codec pack)
Thunderbolt8 is offline   Reply With Quote
Old 29th August 2014, 16:07   #16  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
for %%a in (*.mkv) do mkvmerge -o "output\%%a" "%%a" "%%~na.dtsma" "%%~na.ass"
sneaker_ger is offline   Reply With Quote
Old 29th August 2014, 17:06   #17  |  Link
Thunderbolt8
Registered User
 
Join Date: Sep 2006
Posts: 2,197
where do I need to make the change if each output file should have a slightly different name if I choose to output in the same directory?

e.g. instead of blablaS01E01.mkv/.dtsma/.ass all output names should be named "outputblablaS01E01.mkv" so I wont override my input video file.

edit: its got to be

for %%a in (*.mkv) do mkvmerge -o "output%%a" "%%a" "%%~na.dtsma" "%%~na.ass"

then, right?
__________________
Laptop Lenovo Legion 5 17IMH05: i5-10300H, 16 GB Ram, NVIDIA GTX 1650 Ti (+ Intel UHD 630), Windows 10 x64, madVR (x64), MPC-HC (x64), LAV Filter (x64), XySubfilter (x64) (K-lite codec pack)

Last edited by Thunderbolt8; 29th August 2014 at 18:15.
Thunderbolt8 is offline   Reply With Quote
Old 29th August 2014, 21:25   #18  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Yes, that's it.
sneaker_ger is offline   Reply With Quote
Old 30th August 2014, 01:14   #19  |  Link
fryk
Member
 
fryk's Avatar
 
Join Date: Aug 2012
Posts: 18
Quote:
Originally Posted by sneaker_ger View Post
@fryk
You forgot to supply a TrackID for the --language parameter
You are completely right, thank you so much!

Wer lesen kann, ist echt im Vorteil

--language TID:language

Sets the language for the given track (see section track IDs). Both ISO639-2 language codes and ISO639-1 country codes are allowed. The country codes will be converted to language codes automatically. All languages including their ISO639-2 codes can be listed with the --list-languages option.

This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time.
fryk is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 14:49.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.