Re: Extract untouched audio track from mkv/webm programatically
Moritz Bunkus <[email protected]> Tue, 12 Mar 2013 18:38:45 +0100
| Newsgroups | gmane.comp.multimedia.matroska.user |
|---|---|
| Message-ID | <CANPayMQShUs3M_4pYgE0ns5YFC9jvgLmOBEHHLC1046qaw-0vQ@mail.gmail.com> |
Hey, On Tue, Mar 12, 2013 at 6:24 PM, Róbert Kohányi <[email protected]> wrote: > Now, this is the point where I'm stuck. I've read the manual/specification > for EBML but I'm not sure if I got it right. As I understood it the actual > data (video and/or audio) are located *inside* the Cluster element, Correct so far, but there can be an unlimited number of cluster elements, not just one. > How can I identify the Block/SimpleBlock elements belonging to a particular > TrackEntry? The SimpleBlock and Block structures are not EBML master elements with child elements (simply due to the overhead that would incur). Their binary structure is described in the Matroska specifications here[1] for SimpleBlocks and here[2] for Blocks. Code that reads both structures can be found in libmatroska[4]. The SimpleBlock and BlockGroup binary structures do indeed contain a track number which corresponds to the "TrackNumber" child element of a TrackEntry structure. > But, let's say I've found all the Block/SimpleBlock elements that belong to > a single audio ogg vorbis audio track. Can I just *append* these after each > other and be done with it? For Vorbis? No. You'll have to frame them in Ogg packets. For an idea how that is usually done: mkvextract contains code[3] just for this. However, it does use libvorbis & libogg from http://www.xiph.org for this purpose. If you cannot use those libraries you'll have to write the Ogg framing yourself. You should get help for that elsewhere, though, where there are more Ogg experst ;) (Xiph has mailing lists for Vorbis) Kind regards, mosu [1] http://www.matroska.org/technical/specs/index.html#simpleblock_structure [2] http://www.matroska.org/technical/specs/index.html#block_structure [3] https://github.com/mbunkus/mkvtoolnix/blob/master/src/extract/xtr_ogg.cpp#L69 for the header pages and https://github.com/mbunkus/mkvtoolnix/blob/master/src/extract/xtr_ogg.cpp#L184 for how a single frame would be written [4] https://github.com/Matroska-Org/libmatroska/blob/master/src/KaxBlock.cpp#L414 reads the "head" of the Block/SimpleBlock structure, the frames contained therein are read starting from https://github.com/Matroska-Org/libmatroska/blob/master/src/KaxBlock.cpp#L450 _______________________________________________ Matroska-users mailing list [email protected] http://lists.matroska.org/cgi-bin/mailman/listinfo/matroska-users Read Matroska-Users on GMane: http://dir.gmane.org/gmane.comp.multimedia.matroska.user