coding-socks / ebml

An EBML parser written in Go.
MIT License
2 stars 0 forks source link

Support EBML Stream / Matroska Livestreaming #1

Open nerg4l opened 3 years ago

nerg4l commented 3 years ago

To make this work the library has to handle elements with Unknown Data Size and multiple Documents (or continuous Header and Segment elements).

EBML Stream

An EBML Stream is a file that consists of one or more EBML Documents that are concatenated together. An occurrence of an EBML Header at the Root Level marks the beginning of an EBML Document.

Source: https://www.rfc-editor.org/rfc/rfc8794#name-ebml-stream

Matroska Livestreaming

Livestreaming

[...]

A live Matroska stream is different from a file because it usually has no known end (only ending when the client disconnects). For this, all bits of the “size” portion of the Segment Element MUST be set to 1. Another option is to concatenate Segment Elements with known sizes, one after the other. This solution allows a change of codec/resolution between each segment. For example, this allows for a switch between 4:3 and 16:9 in a television program.

[...]

Source: https://www.matroska.org/technical/streaming.html

nerg4l commented 1 year ago

To better support streaming the plan is to replace io.ReadSeeker with io.ReaderAt and use stack instead of recursion. This could simplify the detection of the end of Unknown Data Size elements.