VideoHelp Forum
+ Reply to Thread
Results 1 to 16 of 16
Thread
  1. Hi everyone,

    I want to add 3 chapters to upwards of 35 MKV files at the same time (without having to add them one by one)

    - Default chapter 00:00:00
    - Intro: The intro time for ALL files is exactly the same.
    - Outro: The outro is the same in duration but the files are not the same in length.

    Questions:
    - Is there a way to add chapters to all the files at the same time instead of one by one?
    - Is there a way to make the outro chapter count negatively from the total duration of the video?
    i.e. One file is 10 minutes and another is 11 and the outro is 15 seconds, make the outro count -15 seconds from the end of each video so its marker would be at 00:09:45 for the first file but it would be at 00:10:45 for the second (and the same would apply for the rest of the MKVs).

    macOS High Sierra 10.13.3 in case there are any software recommendations.
    Quote Quote  
  2. Hard questions!

    I can give you some directions, I don't use MKV in years.
    - Is there a way to add chapters to all the files at the same time instead of one by one?
    Do you know MKVToolnix?
    Drag all your files in to it, load the chapters at the chapter tab and run, you'll have to try and work it out to fit your needs.

    If I remember right, this tool show a command line, you can copy that and do something like this at yout terminal:
    Code:
    for f in *.mkv; do "command $f"; done
    Last edited by amaipaipai; 27th May 2018 at 18:38.
    Quote Quote  
  3. Thank you for your response!
    I know MKVToolnix and I have it, but I'm not sure I understand your instructions. Can you make it more newbie-friendly please?
    Quote Quote  
  4. Drag and drop all your files over the tool, load the chapters and click apply.
    Quote Quote  
  5. I don't think mkvtoolnix has a built-in way to set times as negative integers from the end. You'd have to write a script/program yourself that calculates them from the duration (the duration you can get via e.g. mkvinfo or MediaInfo).
    Quote Quote  
  6. As stated, he need to see the tool working and adapt for his needs. There's no magic script to do what he need with one click, he need to calculate and create the chapters he needs to apply to.
    Quote Quote  
  7. This thread has many examples of how to use FOR loops in batch files to process many files:

    https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg

    What you want to do is get the length of the video with MkvInfo or MediaInfo or ffprobe, subtract 15 seconds, then pass that to MkvMerge as a chapter point.
    Quote Quote  
  8. Originally Posted by jagabo View Post
    This thread has many examples of how to use FOR loops in batch files to process many files:

    https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg.
    He's not on Windows.
    Quote Quote  
  9. Originally Posted by sneaker View Post
    Originally Posted by jagabo View Post
    This thread has many examples of how to use FOR loops in batch files to process many files:

    https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg.
    He's not on Windows.
    You're right. I missed that. But similar tools exist on the Mac.
    Quote Quote  
  10. Originally Posted by amaipaipai View Post
    Drag and drop all your files over the tool, load the chapters and click apply.
    Are you saying there is no way to automate this operation and I have to do the files one by one?


    Originally Posted by sneaker View Post
    I don't think mkvtoolnix has a built-in way to set times as negative integers from the end. You'd have to write a script/program yourself that calculates them from the duration (the duration you can get via e.g. mkvinfo or MediaInfo).
    Does that mean programming knowledge is required? Or is that something simple to learn?


    Originally Posted by jagabo View Post
    Originally Posted by sneaker View Post
    Originally Posted by jagabo View Post
    This thread has many examples of how to use FOR loops in batch files to process many files:

    https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg.
    He's not on Windows.
    You're right. I missed that. But similar tools exist on the Mac.
    Do you think Handbrake is a good alternative? Is there something better you can recommend?
    Quote Quote  
  11. Originally Posted by Shady View Post
    Do you think Handbrake is a good alternative? Is there something better you can recommend?
    I'm not an expert on this, but I'm not aware of any tool that lets you specify chapter points relative to the end of the video.
    Quote Quote  
  12. Are you saying there is no way to automate this operation and I have to do the files one by one?
    Read again:
    https://forum.videohelp.com/threads/389108-Batch-Adding-Chapters-to-Multiple-MKV-Files#post2520852

    Then copy the "command" to a bash script and run:
    Code:
    for f in *.mkv; do "command $f"; done
    It will apply chapters to all your mkv files, if this files has different timings you need to calculate it before running the script.
    Quote Quote  
  13. Originally Posted by Shady View Post
    Does that mean programming knowledge is required?
    Yes, some basic programming knowledge is required to automatically read the duration data from e.g. MediaInfo, modify it, write it to chapter files and then mux the files.
    Quote Quote  
  14. Originally Posted by amaipaipai View Post
    Are you saying there is no way to automate this operation and I have to do the files one by one?
    Read again:
    https://forum.videohelp.com/threads/389108-Batch-Adding-Chapters-to-Multiple-MKV-Files#post2520852

    Then copy the "command" to a bash script and run:
    Code:
    for f in *.mkv; do "command $f"; done
    It will apply chapters to all your mkv files, if this files has different timings you need to calculate it before running the script.
    We might be using different versions of MKVToolNix, because on mine you can't open multiple files under the same instance in the chapter editor.
    That or I still don't really understand the instructions clearly.

    Originally Posted by sneaker View Post
    Originally Posted by Shady View Post
    Does that mean programming knowledge is required?
    Yes, some basic programming knowledge is required to automatically read the duration data from e.g. MediaInfo, modify it, write it to chapter files and then mux the files.
    Although I don't have the programming knowledge to try this approach, I think I understand it.
    Thank you
    Quote Quote  
  15. Originally Posted by Shady View Post
    We might be using different versions of MKVToolNix
    Maybe we are.


    Originally Posted by Shady View Post
    because on mine you can't open multiple files under the same instance in the chapter editor.
    That or I still don't really understand the instructions clearly.
    You don't need to open multiple instances of the chapter editor, all you have to do is to get the COMMAND

    Code:
    for f in *.mkv; do what_ever_mkvtoonix_command_is_doing_to_mux_your_chapters_to_the_files$f; done
    $f will be replaced by the full mkv name+extension (example.mkv), so...

    Code:
    for f in *.mkv; do ""/usr/bin/mkvmerge" --ui-language en --output ^"D:\videos\$f^" --language 0:und --language 1:por ^"^(^" ^"D:\videos\$f^" ^"^)^" --chapter-language eng --chapter-charset UTF-8 --chapters ^"D:\videos\CHAPTER.xml^" --chapter-language eng --generate-chapters when-appending --track-order 0:0,0:1"; done
    That is how I would do it, there's no magic wand to do the heavy work for you, you have to define some parameters first. If it is one chapter to match different files it might work. Now, if you need a different chapter file for dozen different files, all with different timings. Then you need to find some one to program that specific function to you so it might meet your specific need.

    Sorry, I don't know how to help you with that.
    Quote Quote  
  16. Thank you for the detailed explanation, things are much clearer now.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!