VideoHelp.com Forum
+ Reply to Thread
Results 1 to 17 of 17
Thread
  1. Member RogerTango's Avatar
    Join Date: Nov 2007
    Location: United States
    I am using VirtualDubMod to create H264 .MKV videos with, muxing the AC3 from a DVD. But Id like to add chapters. And I dont know how they are built.

    From what I am reading, it is an XML file. Does the filename matter?

    Is the below a proper formatted XML for an MKV chapter list?
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd">
    <Chapters>
    <EditionEntry>
    <ChapterAtom>
    <ChapterTimeStart>00:00:00.000</ChapterTimeStart>
    <ChapterTimeEnd>00:00:09.999</ChapterTimeEnd>
    <ChapterDisplay>
    <ChapterString>Chapter 1</ChapterString>
    <ChapterLanguage>und</ChapterLanguage>
    </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
    <ChapterTimeStart>00:00:10.000</ChapterTimeStart>
    <ChapterTimeEnd>00:00:19.999</ChapterTimeEnd>
    <ChapterDisplay>
    <ChapterString>Chapter 2</ChapterString>
    <ChapterLanguage>und</ChapterLanguage>
    </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
    <ChapterTimeStart>00:00:20.000</ChapterTimeStart>
    <ChapterTimeEnd>00:00:20.999</ChapterTimeEnd>
    <ChapterDisplay>
    <ChapterString>Chapter 3</ChapterString>
    <ChapterLanguage>und</ChapterLanguage>
    </ChapterDisplay>
    </ChapterAtom>
    </EditionEntry>
    </Chapters>
    Id like to write a quickie VB6 proggie that I can tell it the length of a movie I am encoding, and how many chapters to insert, and have it gen me an XML file to IMPORT into VDubMod.

    One last thing, the time...
    The format "00:00:20.999" doesnt make sense to me.

    Is this "Hours:Minutes:Seconds:Miliseconds" ??

    Thanks,
    Andrew
    Quote Quote  

  2. Member JjMon's Avatar
    Join Date: Jan 2006
    Location: United States
    First you would have to extract the chapter using ChapterXtractor from the DVD, then use MKVtoolnix to remux it all together. Or you can use AnyDVD with Handbrake to encode to MKV yielding all all the steps.
    Quote Quote  

  3. Member RogerTango's Avatar
    Join Date: Nov 2007
    Location: United States
    Thanks for the prompt response, but your off track of what I want to do. I hope a more advanced digital video user can offer assistance.

    Thanks,
    Andrew
    Quote Quote  

  4. Greetings Supreme2k's Avatar
    Join Date: Feb 2003
    Location: Right Here, Right Now
    Originally Posted by RogerTango
    Id like to write a quickie VB6 proggie that I can tell it the length of a movie I am encoding, and how many chapters to insert, and have it gen me an XML file to IMPORT into VDubMod.
    Here's a little more info on mkv chapters, including an example xml file.

    One last thing, the time...
    The format "00:00:20.999" doesnt make sense to me.

    Is this "Hours:Minutes:Seconds:Miliseconds" ??
    Yes.


    ===================
    Actually, Jjmon's advice is not too far off. Handbrake is a great tool for getting the chapters from the DVD without having to go through all the script writing. It seems like you're trying to re-invent the wheel. No need to get so condescending.
    Quote Quote  

  5. Zilla God Des's Avatar
    Join Date: Oct 2001
    Location: USA
    I use AutoMKV which imports the chapters automatically into the final MKV file.

    --dES
    "You can observe a lot by watching." - Yogi Bera
    Quote Quote  

  6. Member RogerTango's Avatar
    Join Date: Nov 2007
    Location: United States
    Thanks 2K, for the link an the info, very helpful!

    Andrew
    Quote Quote  

  7. Member RogerTango's Avatar
    Join Date: Nov 2007
    Location: United States
    Can someone tell me if this would be a valid chapter list??

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd">
    <Chapters>
    <EditionEntry>
    <ChapterAtom>
    <ChapterTimeStart>00:00:00.000</ChapterTimeStart>
    <ChapterDisplay>
    <ChapterString>Chapter 1</ChapterString>
    <ChapterLanguage>eng</ChapterLanguage>
    </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
    <ChapterTimeStart>00:10:00.000</ChapterTimeStart>
    <ChapterDisplay>
    <ChapterString>Chapter 2</ChapterString>
    <ChapterLanguage>eng</ChapterLanguage>
    </ChapterDisplay>
    </ChapterAtom>
    </EditionEntry>
    </Chapters>
    Whereas chapter 1 starts at zero time and chapter 2 starts at 10 minutes.

    I am fiddling with the VB code now..

    Thanks,
    Andrew
    Quote Quote  

  8. Member
    Join Date: Dec 2009
    Location: Australia
    How is this coming along, i would love to have a copy of it!
    Quote Quote  

  9. Member RogerTango's Avatar
    Join Date: Nov 2007
    Location: United States
    For more information, follow this thread:
    http://forum.videohelp.com/topic363433.html

    Here is a download link to the stand alone version for all Win32 and 64 flavors:
    http://rogertango.com/download/rtmkvcm-standalone.zip

    Just unpack the ZIP, and run the executable (.EXE).

    Andrew
    Quote Quote  

  10. Member
    Join Date: Apr 2003
    Location: Carson City, NV
    Andrew,

    Thanks so much for this -- this was *exactly* what I needed for my BR rips (I don't really care about the chapters on the disc so much as I just want "stops" I can go to with my WDTV).

    I'm not so sure why my MKV files come out slightly smaller when I mux chapters into them (using MKVMERGE) but I don't really care. Thanks again for this utility which now has a place on my desktop.
    "Like a knife, he cuts through life, like every day's his last" -- Mr. Kiss Kiss Bang Bang
    Quote Quote  

  11. Member RogerTango's Avatar
    Join Date: Nov 2007
    Location: United States
    My WDTV was the original inspiration for the program!

    Andrew
    Quote Quote  

  12. There is also a simpler chapter format which mkvmerge understands and which looks like this:

    CHAPTER01=00:00:00,000
    CHAPTER01NAME=Auto chapter 1
    CHAPTER02=00:14:48,000
    CHAPTER02NAME=Auto chapter 2
    If you have Perl (you do by default on Mac and Linux, and can install it on Windows), this simple Perl script can create such a file:
    Code:
    #!/usr/bin/perl
    ## Make chapters file for MKV
    
    use strict;
    
    my $VERSION=0.01;
    
    my $file = shift;
    my $parts = shift || 10;
    
    unless (-e $file) {
        die "Usage: $0 FILENAME [number_of_chapters]\n";
    }
    
    my ($h, $m, $s) = (0,0,0);
    
    # Find length using either mediainfo or ffmpeg
    
    if (my $info = `mediainfo "$file" 2>/dev/null`) {
        ($h, $m) = $info =~ /^Duration \s+ : \s* (\d+)h \s* (\d+)m /mx;
        unless ($h || $m) {
            die "*** Error: Could not get duration from mediainfo output.\n";
        }
    }
    elsif (my $info = `ffmpeg -i "$file" 2>&1`) {
        warn "FFmpeg: ", $info, "\n";
        ($h, $m, $s) = $info =~ /^ \s* Duration: \s* (\d+):(\d+):(\d+)/mx;
        unless ($h || $m) {
            die "*** Error: Could not get duration from ffmpeg output.\n";
        }
    }
    else {
        die "No mediainfo or ffmpeg program found\n";
    }
    
    my $seconds = $h*3600 + $m*60 + $s;
    my $step = int($seconds/$parts);
    my $chapter = 1;
    
    for (my $i=0; $i < $step*($parts-1); $i+=$step) {
        my $c = sprintf "%02d", $chapter;
        print "CHAPTER$c=", seconds2tc($i) . ",000", "\n",
              "CHAPTER${c}NAME=Auto chapter $chapter\n";
        $chapter++;
    }
    
    sub seconds2tc {
        my $s = shift;
    
        my $h    = sprintf "%02d", int( $s / 3600 );
        $s %= 3600;
    
        my $min = sprintf "%02d", int( $s / 60 );
        $s %= 60;
    
        $s = sprintf "%02d", $s;
    
        return (
                wantarray ? ($h, $min, $s) : join(":", $h, $min, $s)
        );
    }
    It uses mediainfo or ffmpeg to find the length of the file. The script could be enhanced to also accept the length directly as an argument on the command line.
    Quote Quote  

  13. This Perl script is quite close to my needs, but I'm noob for programming. Maybe someone can help me and write something similar. Actually, I need a script or app that will create simple MKV chapter file based on duration of input MKV files that I want to join latter. For example, I want to join my home videos made by digital camera. All scenes are recorded in separate files, that's the way how my camera works. Now, from these recordings I want to create a single movie of one event, but I also want to put chapter mark at the beginning of each recording.
    Does anybody know how can I do this?
    Quote Quote  

  14. mihvel

    You should be able to do everthing you have asked using mkvmerge GUI.

    For example imagine I had three separate files
    file1, length=2m 43s 560ms
    file2, length=2m 06s 120ms
    file3, length=2m 44s 880ms
    the following will join them together and add chapters.

    Load mkvmerge GUI

    File - New
    Click Input tab:
    Add (open file1)
    Append (open file2)
    Append (open file3)

    Chapter Editor - New Chapters
    Click Chapter Editor tab:
    Highlight (new chapter file)
    Add Chapter
    Highlight EditionEntry1
    Add Chapter
    Add Chapter

    Highlight first chapter
    Start: 00:00:00.000
    End: 00:02:43.560
    Name: Video1

    Highlight second chapter
    Start: 00:02:43.560
    End: 00:04:49.680
    Name: video2

    Highlight third chapter
    Start: 00:04:49.680
    End: 00:07:34.440
    Name: video3

    Click Set Values
    Set language to: eng (English)
    Set country to: uk

    Chapter Editor - Save
    my_chapters.xml

    Click Global Tab
    Chapters file: (Browse and open my_chapters.xml)

    Start Muxing

    Note: You could also add sub chapters if you wish so you could play a particular start and end point within a chapter.

    Hope it helps.
    Last edited by Martin894; 20th Aug 2010 at 18:46.
    Quote Quote  

  15. Martin894, thanks for reply, but that's not exactly what I mean. I'm aware that I can do it manually, using mkvmerge GUI, but I want to do this automatically, using some script capable to read length of the input files and to create a chapter file.
    Anyway, thank you for the try.
    Quote Quote  

  16. Member
    Join Date: Sep 2010
    Location: Canada
    Does anyone know where to get a copy of Roger Tango's MKV chapter tool? His links on his site are not working and neither is his page for contacting him.
    Quote Quote  

  17. Originally Posted by RogerTango View Post
    My WDTV was the original inspiration for the program!

    Andrew
    I have 1st gen WD HDTV player. If you hit FF button, then Next button, it will jump ahead 10 minutes.. or to the next 10 minute interval.. not sure. Trouble with that thing is soft subs easily go out of sync if you do more than Pause/Play. I usually burn them in for that reason.

    I'm looking to go the other way. Extract a chapter file from an .mkv then convert it to HH:MM:SS that DvdAuthorGui uses.
    At this point I have a small AutoIt3 script but I have to preprocess the xml with Opera and save as text to get the xml elements on separate lines. Just easier to pick out the chapter start times that way.

    I have files for 5 minute, 8 minute and 10 minute intervals for use in DvdAuthorGui but I thought it would be cool to go to the chapters set in the original, when outputting to DVD. There are tools like BD Rebuilder that do it all for me, but I'm messing around with using HCgui manually to encode to DVD.

    Seems to be tough to find general-purpose xml parsers.

    Just thought I'd chime in since it's related.
    I'll download your tool for my video toolbox.
    If I get my AutoIt3 script so that it works stand-alone without passing the xml through Opera then I'll post it for everyone to access.

    edit: I tried the compiled script on a couple of .mkv chapter files produced by MkvExtractGui-2 and it worked fine. If anyone would like to use it you can download from my site using this link:

    http://www.favessoft.com/HmsTimes.zip
    Last edited by MilesAhead; 26th Nov 2010 at 19:21.
    http://www.FavesSoft.com

    "I don't want to belong to any club that would have me as a member."
    - Groucho Marx
    Quote Quote  




Similar Threads

  1. MKV XML chapter file creator
    By perdigueiro in forum Linux
    Replies: 3
    Last Post: 30th Jan 2012, 08:44
  2. mkv chapter file problem
    By Bully9 in forum Editing
    Replies: 12
    Last Post: 22nd Mar 2010, 18:06
  3. MKV chapter file extraction problems
    By ikarishinji41 in forum Editing
    Replies: 1
    Last Post: 22nd Mar 2010, 11:03
  4. How to create chaptering in MKV or Xvid video file ?
    By c1steady in forum Newbie / General discussions
    Replies: 1
    Last Post: 7th Jan 2010, 11:38
  5. Replies: 3
    Last Post: 5th Jun 2009, 20:24
Search   Contact us   About   Advertise   Forum   RSS Feeds   Statistics   Tools