VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 4 of 4
Thread
  1. 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.
    Last edited by VideoFanatic; 29th Dec 2019 at 04:26.
    Quote Quote  
  2. 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.
    Quote Quote  
  3. 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 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.
    Last edited by VideoFanatic; 29th Dec 2019 at 04:27.
    Quote Quote  
  4. 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:
    What I don't understand here is that, according to your explanations, the input video should be a MP4 file, but according to the command line it appears to be a MKV file.

    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?
    It seems to be similar, but that version must be seriously outdated, as I have v. 35.0.0 and it's from June 2019. It should work fine though, but I suppose that many improvements have been made (especially with regards to the support of newer formats) and many bugs ironed out in the mean time. It is possible that v. 8.5.1 did not support .sup subtitle files, although I can't confirm this at the moment.

    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.
    You can find a basic but thorough description of the FOR loop command here :
    https://ss64.com/nt/for.html
    Or you can read the integrated help by typing :
    Code:
    FOR /? >"X:\FOR.txt"
    then opening that text file (more convenient than reading directly from the command prompt, in several pages usually, or it outputs everything and only the end is accessible).
    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"
    then opening that text file. With this as a starting point you can learn a lot by doing small tests on your own.

    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
    Notes :
    • 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 12:30.
    Quote Quote  



Similar Threads