Subject: [Cellar] How to use libmatroska?

From: Austin Einter <[email-masked]>
Date: Tue, 16 Jan 2018 07:02:06 +0530

Say I have a MKV file.

How do I parse it?
How do I write a new MKV file?

I hope libmatroska can do this.
Is there any sample code / example that I can refer to read / write
matroska files.

Thanks
Austin

---

From: Dave Rice <[email-masked]>
Date: Tue, 16 Jan 2018 10:50:00 -0500

Hi Austin,

> On Jan 15, 2018, at 8:32 PM, Austin Einter <[email-masked]> wrote:
> 
> Say I have a MKV file.
> 
> How do I parse it?

For parsing an MKV file I suggest reviewing the EBML specification at https://datatracker.ietf.org/doc/draft-ietf-cellar-ebml/ <https://datatracker.ietf.org/doc/draft-ietf-cellar-ebml/>, particularly the principles of the EBML Element and its Element ID, Element Data Size, and Element Data. Understanding how to read EBML Elements will help decipher the structure of a Matroska file (or any other EBML document). Then the EBML Schema of that file type is needed in order to understand the semantics of each element. For Matroska that EBML Schema is available at https://github.com/Matroska-Org/matroska-specification/blob/master/ebml_matroska.xml <https://github.com/Matroska-Org/matroska-specification/blob/master/ebml_matroska.xml>.

> Is there any sample code / example that I can refer to read / write matroska files.
> 
> Thanks
> Austin
> _______________________________________________
> Cellar mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/cellar

---

From: Steve Lhomme <[email-masked]>
Date: Sun, 21 Jan 2018 17:28:53 +0100

Hi,

I think this question should go in matroska-devel rather than the
CELLAR mailing list.

That being said, libmatroska doesn't come with good example code nor
good documentation. it's a rather low level API to the format that
doesn't do a lot of things for you (it even allows writing incorrect
files if you want to do that on purpose).

Also since Matroska is an interleave audio/video(/other) format,
writing means you have to handle the interleaving yourself. There are
higher level APIs that can do that for you like libavformat (from
ffmpeg/libav).

2018-01-16 16:50 GMT+01:00 Dave Rice <[email-masked]>:
> For parsing an MKV file I suggest reviewing the EBML specification at
> https://datatracker.ietf.org/doc/draft-ietf-cellar-ebml/, particularly the
> principles of the EBML Element and its Element ID, Element Data Size, and
> Element Data. Understanding how to read EBML Elements will help decipher the
> structure of a Matroska file (or any other EBML document). Then the EBML
> Schema of that file type is needed in order to understand the semantics of
> each element. For Matroska that EBML Schema is available at
> https://github.com/Matroska-Org/matroska-specification/blob/master/ebml_matroska.xml.
>

-- 
Steve Lhomme
Matroska association Chairman