I tried this script but the subtitles always turn on by them-self when playing the video back even if you set default subs to no and forced subs to no: https://gist.github.com/seyoum/6433a981c233ff224b46753695b3ff8b#file-video-and-subtitl...r-mkvmerge-bat
When I manually use MKVToolnixGUI I can get the subtitles to stay turned off when playing back a video by doing this: I give the subtitle track a name like "English Subtitles".
I have to set the language to Undetermined (und) or else the subs will turn on by them-self when playing the video back even if you set default subs to no and forced subs to no.
I set Default Track to No
I set Force Track to No
Does anyone have a batch script that does all of the above please. I have multiple videos in the same folder and each video has a srt subtitle file with the same filename as the video. Videos are all titled VideoName.mp4. Would like it to output VideoName.mkv for example and have the subtitle file embedded in the video. Audio is AAC and will stay as that format.
Mods
I would like to make the following mods to this script:
- I would like the script to support .sup files which is what Bluray uses.
- Instead of it asking where MKVMerge is located, just have the location already in the script such as this: X:\Portable Installations\MKV Toolnix/mkvmerge.exe
That way there's no wasting time asking where the script is if it's always the same location.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 8 of 8
Thread
-
Last edited by VideoFanatic; 29th Dec 2019 at 03:26.
-
If you get the intended result for one file in MKVToolNix GUI, you can get the corresponding mkvmerge command by clicking on "Multiplexer" => "Show command line". Then you can adapt it with a basic FOR %%i in (*.mkv) DO ... script to batch process all files in a folder in the same way. If you don't know how to do that, copy the mkvmerge command line here, so someone can complete it as required.
-
OK. I dragged an MP4 and subtitle SRT file into MKVToolnix GUI then clicked on the subtitle file.
For Track name I entered "English Subtitles".
Language: Undetermined (und)
Default Track Flag: No
Forced Track Flag: No
Here's the command line:
mkvmerge.exe ^"--ui-language^" ^"en^" ^"--output^" ^"J:/0Working/z = Batch Encode/Subtitle Test/New Folder/Raw 1999 Dec 20 ^(1^).mkv^" ^"--language^" ^"0:und^" ( ^"J:/0Working/z = Batch Encode/Subtitle Test/New Folder/Raw 1999 Dec 20.srt^" ) ^"--language^" ^"0:und^" ^"--default-track^" ^"0:yes^" ^"--language^" ^"1:eng^" ^"--default-track^" ^"1:yes^" ^"--language^" ^"2:und^" ^"--track-name^" ^"2:English Subtitles^" ^"--default-track^" ^"2:no^" ( ^"J:/0Working/z = Batch Encode/Subtitle Test/New Folder/Raw 1999 Dec 20.mkv^" ) ^"--track-order^" ^"0:0,1:0,1:1,1:2^"
I would like to make the following mods to this script:
- I would like the script to support .sup files which is what Bluray uses.
- Instead of it asking where MKVMerge is located, just have the location already in the script such as this: X:\Portable Installations\MKV Toolnix/mkvmerge.exe
That way there's no wasting time asking where the script is if it's always the same location.
Last edited by VideoFanatic; 29th Dec 2019 at 03:27.
- I would like the script to support .sup files which is what Bluray uses.
-
Surprised that noone replied to this in a week – but it may not have been the ideal time of the year to get replies about anything anywhere !
Here's the command line:
I don't have Multiplexer > Show command line on my 8.5.1 program. Instead I just go to Merge > Show command line. Is that OK?
I would like to make the following mods to this script:
I would like the script to support .sup files which is what Bluray uses.
Instead of it asking where MKVMerge is located, just have the location already in the script such as this: X:\Portable Installations\MKV Toolnix/mkvmerge.exe
That way there's no wasting time asking where the script is if it's always the same location.
https://ss64.com/nt/for.html
Or you can read the integrated help by typing :
Code:FOR /? >"X:\FOR.txt"
You can get a thorough description of the available commands and switches in your installed version of mkvmerge by typing :
Code:"X:\Portable Installations\MKV Toolnix\mkvmerge.exe" -h >"X:\mkvmerge help.txt"
I don't have enough experience in that field to be perfectly confident that there should be no mistake, but this should work as intended :
Code:FOR %%F in (*.mp4) DO "X:\Portable Installations\MKV Toolnix\mkvmerge.exe" --ui-language en --output "%%~dpnF.mkv" --language 0:und --default-track 0:yes --language 1:eng --default-track 1:yes ( "%%F" ) --language 0:eng --default-track 0:no --track-name "0:English Subtitles" ( "%%~dpnF.sup" ) --track-order 0:0,1:0,1:0
- With mkvmerge, the output appears first, then the input files.
- I removed the "^" (escape characters) and most of the "" quotations marks which are unnecessary when the command is used outside of MKVToolNix. And I put the MP4 input file first, then the SUP input file, as it seems more logical. That way the --track-order option is facultative in this case, as the tracks are added by default to the output file in the same order as they are found in the input files (video track from the MP4, audio track from the MP4, subtitle track from the SUP). With MP4 files this should work consistently, but with MKV files as input the actual order of tracks can be different (for instance a subtitle track can be in 0, an audio track in 1, a second subtitle track in 2, the video track in 3, and a second audio track in 4), which can be a problem when doing batch conversion if the track order of all input video files don't match.
- "%%~dpnF" means : the drive letter followed by the path followed by the name (without the extension) of the file "%%F". It is equivalent to "%%~dF%%~pF%%~nF". "%%F" is equivalent to "%%~dpnxF" or "%%~dF%%~pF%%~nF%%~xF", i.e. it stands for the complete file name including the drive letter (%%~dF), the path (%%~pF), the actual name (%%~nF) and the extension (%%~xF). Any letter can be used instead of "F", provided that the same letter is then used everywhere in the command, with the same case type (it's best to use upper case letters, to avoid confusion with the lower case parameters). The quotation marks are necessary if there's at least one space in the path or name, and don't break anything if they're used when not required, so it's best to always put them just in case.
- That command should work in a .bat batch file put in the same directory as the input files. If typing or pasting the command directly into the command prompt, every instance of "%%" should be replaced by a single "%" percent sign. If the .bat file is placed in a different directory, the source directory has to be specified with : FOR /R "X:\path\to\the\source directory" "%%F" (etc.) ; when /R is used, then all the subdirectories (if any) are processed as well. Or you can open the source directory first with a separate CD command : CD "X:\path\to\the\source directory" followed by a line break (if X: is not the default drive letter, first type X: followed by a line break before the CD command). Likewise, if running the command from the command prompt, the source directory should be opened first : X: [ENTER] CD "X:\path\to\the\source directory" [ENTER]. A nice trick I learned here is to right-click on a directory icon with the SHIFT key pressed, which makes some extra context menu items appear, including "Open a command prompt here", which will automatically set the working directory to the intended path.
- "X:\Portable Installations\MKV Toolnix/mkvmerge.exe" could be replaced by simply "mkvmerge" (without the quotation marks) if the location of the executable is included in the Windows PATH.
https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/
In order to avoid doing that fastidious modification, I created a single "CLI" directory which I included in the PATH and where I put all CLI executable files which are regularly needed – more specifically I put a hard link (conveniently created with LinkShellExtension), which allows to have two or more instances of the same file in several directories while occupying the space of a single instance (definitely useful for large executable files like ffmpeg.exe which has inflated to about 60MB by now and can be found in the subdirectories of many utilities which rely on it under the hood). - If there's an error with .sup files and .srt files work fine (and both have the same name minus the extension), updating mkvmerge should do the trick.
Last edited by abolibibelot; 6th Jan 2020 at 11:30.
-
I think I'm a little late but hope it helps future visitors.
I think what you're looking for is having cmd open with mkvtoolnix ready in directory of your choice.
To do this..
Just add mkvtoolnix directory to Path in environment variables.
To do this, serach for Advanced system settings in Start (alternatively, you can go to Propeties of This PC and find it on the left pane)
Then open Environment Variables (at bottom) > Find 'Path' under System Variables (bottom pane) > Click on 'Edit' > Click on 'New' and Add your mkvtoolnix direcotory to this list.
To open cmd in folder containing videos, hold shift+right click.
On windows 10 however Powershell replaces cmd in context menu.
To add it, go here and use steps 3 & 4 to add/remove cmd to context menu.
With this you can directly use mkvmerge and mkvpropedit as commands. (Example shown below)
Thank you! This is exactly what I was looking for.
I was also able to simplify this with the help while searching on another thread.
Code:for %a in (*.mp4) do mkvmerge -o "%~dpna.mkv" "%~a" --forced-track "0:no" --default-track "0:yes" --track-name "0:Track 1" --language "0:eng" "%~na.srt"
This requires the video and subtitle to have same file names,
Input/output extensions can also be interchanged. (mkv/mp4 but remuxed mp4 does not show file preperties like video resolution, bitrates and audio info.) -
I just happen to visit this forum again after a few months of absence, surprised to see that this thread got a new reply just a few days ago (and none from the person who asked).
As I wrote above :
« If typing or pasting the command directly into the command prompt, every instance of "%%" should be replaced by a single "%" percent sign. »
So the script above would work from the command prompt, while the one I proposed would work as a .bat file.
Also, using a capital letter for the variable (%A, %F, %I...) is advised as it makes the code a bit clearer, by distinguishing the variable itself from its modifiers (~d, ~p, ~n, etc.) ; but it works just the same so long as the same case is used.
I was also able to simplify this with the help while searching on another thread.
Input/output extensions can also be interchanged. (mkv/mp4 but remuxed mp4 does not show file preperties like video resolution, bitrates and audio info.) -
One of many that got me started with the scripts. (Sorry, still a noob in scripts but I'm starting to get how it works)
Input/output extensions can also be interchanged. (mkv/mp4 but remuxed mp4 does not show file preperties like video resolution, bitrates and audio info.)
Not sure I understood that part correctly... Unless it has changed lately, mkvmerge only outputs MKV/MKA files.
I used this script earlier to merge video and subtitles.
Code:for %A in (*.mkv) do mkvmerge -o "remux-%~nxA" "%~A" --forced-track "0:no" --default-track "0:yes" --track-name "0:Track 1" --language "0:eng" "%~nA.srt"
But in your script having d p n modifiers with specified output, it is able to change input or output as desired.
This is exactly what I was after, so thank you. I did try to get the code off of GUI but wasn't able to simplify or get it work for batch in terminal.
Using this simply to convert..
Code:for %A in (*.mp4) do mkvmerge -o "%~dpnA.mkv" "%~A"
Would appreciate a brief explanation on how modifiers (d, p, n) function. Or if you could highlight a link.
(Just hovered over documentation and I didn't find it :]
And thanks for educating me on other conventions used to make script clear -
Would appreciate a brief explanation on how modifiers (d, p, n) function. Or if you could highlight a link.
(Just hovered over documentation and I didn't find it :]
https://ss64.com/nt/syntax-args.html
You can test the effect with "echo", with "cd" open any folder (containing about 5-10 files) then type :
Code:for %A in (*) do echo "%~dA" for %A in (*) do echo "%~pA" for %A in (*) do echo "%~nA" for %A in (*) do echo "%~xA" for %A in (*) do echo "%~nxA" for %A in (*) do echo "%~dpnxA"
Code:for /?
Code:for /? >"E:\CMD FOR help.txt
I don't know about codecs in depth but I'm assuming it is able to swap containers like mkv/mp4/avi within input/output.
I used this script earlier to merge video and subtitles.
Code:for %A in (*.mkv) do mkvmerge -o "remux-%~nxA" "%~A" --forced-track "0:no" --default-track "0:yes" --track-name "0:Track 1" --language "0:eng" "%~nA.srt"
But in your script having d p n modifiers with specified output, it is able to change input or output as desired.
Using this simply to convert..
Code:for %A in (*.mp4) do mkvmerge -o "%~dpnA.mkv" "%~A"
What exactly is your question here, or what is puzzling you, if anything ?
Similar Threads
-
Need help with Batch Script for Normalizing Audio of Video
By VideoFanatic in forum Video ConversionReplies: 1Last Post: 4th Feb 2020, 07:54 -
Combining audio and video in avisynth script
By killerteengohan in forum RestorationReplies: 1Last Post: 29th Dec 2018, 10:04 -
Batch script for forcing subtitles on MKV files.
By hemstock in forum SubtitleReplies: 2Last Post: 9th Oct 2015, 15:40 -
A batch/Python script to Mux subtitles with video
By Scavvy in forum ProgrammingReplies: 4Last Post: 6th Jul 2015, 03:23 -
batch script that remux multiple movies and subtitles together to mkv file
By galiber12 in forum SubtitleReplies: 2Last Post: 16th Jan 2015, 16:38