[Matroska-devel] How can I concatenate / append / combine segments of Matroska files programatically?

Steve Lhomme slhomme at matroska.org
Sun Jun 29 01:25:46 CEST 2008


Peter Romba wrote:
> Hi guys,
> 
> I'm trying to write a class that will concatenate parts of two Matroska 
> files together.  I've seen examples of this in the mkvmerge program in 
> the mkvtoolnix toolkit.  However, that tool only appends complete 
> files.  I'd like to just append over *parts* of a source file onto the 
> end of a destination file.
> 
> Can anyone recommend the basic ways to do this?  The sample applications 
> included with the library illustrate muxing and reading/writing header 
> data, but it's not clear how to interact with the clusters and move them 
> around and still end up with an intelligible file.

You need to create all the basic parts yourself. Even if you get 
separate clusters, you still need to manage the timecode inside each. 
The other option is to use segment linking.

> As a side note, I haven't had much luck parsing any of the mkv files 
> from the matroska site with the test8 sample application--it seems like 
> it just loops through the files, finds no useful elements, and exits.  
> So that's made it a bit difficult to examine the structure of a known 
> good file.

We are in the process of rewriting the libs (and some better examples) 
in C. The test samples in libmatroska are from early versions of 
libmatroska. The best way to see how to mux matroska is to look at the 
mkvmerge sources. Although it may need a bit of time/work. It is not a 
simple task to concatenate files.

Steve



More information about the Matroska-devel mailing list