Giter Club home page Giter Club logo

mkvtoolnix-batch's Introduction

mkvtoolnix-batch

Description

Windows Batch script to automate batch processing using mkvtoolnix.

Dependencies

Usage

  1. Download MKVToolNix.
  2. Open mkvtoolnix-gui.exe.
  3. Add any of the MKV files to be processed (drag-and-drop works just fine).
  4. Perform your changes within the GUI (disable tracks, rename tracks, set default tracks, etc.).
  5. Go to Menu Bar > Multiplexer > Create option file, and save it as 'options.json' in the same directory where all MKV files to be processed are. You can then close the GUI.
  6. Open said JSON file with your favourite editor and completely delete:
    • The "--output", line along with the one coming right after it.
    • The "(", and ")", lines together with the one in between them.
  7. Find the mkvmerge.exe executable within MKVToolNix and get its path (Shift + Right-Click > Copy as path from Windows File Explorer).
  8. Download mkvtoolnix-batch.bat from this repository and put it in the directory where all MKV files and the JSON are.
  9. Edit mkvtoolnix-batch.bat and replace "D:\...\mkvmerge.exe" with your path to mkvmerge.exe from step 6.
  10. Run mkvtoolnix-batch.bat by double-clicking it.
  11. Go grab yourself a cup of coffee and wait for the multiplexing process to complete. Processed MKV files will appear inside the mkvmerge_out directory.
  12. Profit.

License

Code licensed under GNU General Public License v3.0.

mkvtoolnix-batch's People

Contributors

serede avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mkvtoolnix-batch's Issues

Doubles the audio tracks and subtitles

This code is a life and time saver, thank you for going through the time to make this for everyone

My input files have 2 audio tracks and 2 subtitle tracks. The audio tracks are Japanese and English in that order, the subtitles are English Signs/Songs and English Full in that order. My output files will have 4 audio and subtitle tracks. Japanese, English, Japanese, English. The subtitles would be Signs/Songs, Full, Signs/Songs, Full.

I'm not sure what could be happening here, MKVToolNix GUI output doesn't have this same issue. I'll attach my json file below. Anything helps. Thanks!

[
"--ui-language",
"en",
"--track-name",
"0:HEVC x265 10b",
"--default-track",
"0:yes",
"--display-dimensions",
"0:1440x1080",
"--language",
"1:ja",
"--track-name",
"1:Japanese",
"--language",
"2:en",
"--track-name",
"2:English",
"--default-track",
"2:yes",
"--language",
"3:en",
"--track-name",
"3:English [Signs/Songs]",
"--default-track",
"3:yes",
"--forced-track",
"3:yes",
"--language",
"4:en",
"--track-name",
"4:English [Full]",
"(",
"E:\Videos\TV\Bleach\Disk 1\Bleach - 001.mkv",
")",
"--track-order",
"0:0,0:1,0:2,0:3,0:4"
]

Edit: After running this command, it also comes up with "Warning: 'Bleach - 001.mkv': Could not keep a track's UID 'X' because it is already allocated for another track. A new random UID will be allocated automatically" for every track. X being numbered 1-5 for every track on file. I'm almost certain it isn't an issue with this batch file, but still anything helps. Thanks

Muxing same subs over and over

Hi, i've got a folder with a season of a tv series. It contains 9 episodes and 9 .srt files.
I've modified the script at line 9:
From this:
for %%f in (*.mkv) do %mkvmerge% @options.json -o "mkvmerge_out/%%f" "%%f"
To this:
for %%f in (*.mp4) do %mkvmerge% @options.json -o "mkvmerge_out/%%f.mkv" "%%f"

So the batch grabs the mp4 files and outputs mkv files with subs.

It can mux all episodes but the problem is that it uses only the subtitles i've used to generate the option.json. If i use subtitles of episode 1 it puts at every episode those subs.

...

This only works if you A) have those parameters in your options file, and B) if the file you're trying to batch is MKV already. If you want to batch an entire directory from say, .ts to .mkv. This simply doesn't do that.

This would actually work better:
for %%A IN (*.ts) do ( D:\path\to\MKVToolNix\mkvmerge.exe -o ".\out\%%~nA.mkv" "%%~A") pause
Inside a batch (.bat) file and put into the directory you're converting the files to. *.ts can be any video format mkvmerge accepts, i.e. *.mp4 - then baddaboom-badda-bing, all your new mkv's are in the out directory.

External files

This works to change the internal tracks files from from one container to other. But what happens if I want to add external files like subtitles and audios of several languages? What should be added to the JSON file to continue with the loop conversion?

Json error

This is most likely not a bug bot my stupidity and code illiteracy, but I get the following error when I try to run the script as per instruction.
`Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.
Error: The JSON option file 'options.json' contains an error: [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - unexpected ','; expected end of input.

============================
Done. Press any key to exit.`

My options.json looks like this:

"--ui-language", "en", "--language", "0:eng", "--track-name", "0:Eng Dub", "--language", "0:eng", "--language", "0:und", "--track-name", "0:AAC 5.1", "--language", "0:und", "--track-name", "0:Lyrics/Songs", "--no-subtitles", "--language", "0:und", "--track-name", "0:", "--default-track", "0:yes", "--language", "1:jpn", "--track-name", "1:Flac 2.0", "--language", "0:ger", "--track-name", "0:Ger Dub", "--sync", "0:600", "--track-order", "4:0,2:0,4:1,0:0,5:0,1:0,3:0"

And this is how I'd like everything to turn out:
Desktop Screenshot 2019 08 11 - 18 27 24 63

Adding 2 subtitles failed

Hi,

I wanted to batch multiplex mkv files with subtitle files in srt format. I have 2 subtible files for each mkv file. I followed your tutorial step by step. The batch script was executed without any issues but my output files were created without any subtitle track... Can you please advice on that?

Thank you
SpikeFly

Does this work with .ass files?

I've tried to do this twice now, and both times, the files spat out at the end simply aren't having the subtitles muxed into the video. If i manually add the subtitle tracks, or mux them individually, it works fine. anybody know what I'm missing? i'm following the guide to the letter but it just isn't working. The video files are .mkv files btw.

Extra files

I love this script.
I have a question. Everything works if all variables are in the same file. If I had to add for example an audio or a subtitles from another file, what should I put?
Thank you.
Fabrizio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.