[Matroska-users] How to concatenate segments?
Steve Lhomme
slhomme at matroska.org
Sun May 15 14:17:08 CEST 2011
On Fri, May 13, 2011 at 12:06 AM, jianwen chen
<jianwen.chen.video at gmail.com> wrote:
> Hi,
>
> http://matroska.org/technical/streaming/index.html
> A live Matroska stream is different than a file, because it may have no
> known end (only when the client disconnects). For that the Segment must use
> the "unknow" size (all 1s in the size). The other option would be to
> concatenate Segments with known sizes one after the other. This solution
> allows a change of codec/resolution between each segment which can be useful
> in some cases (switch between 4:3 and 16:9 in some TV programs for example).
>
> I want to enable a streaming with matroska file formats. How to concatenate
> the segments with known sizes one after the other? Is there any guide on
> this?
I know GStreamer can do that. At least from a live source, as there no
good reason to turn one file into a live stream.
If you want to create something like a live TV stream, you fill either
need to hack into GStreamer (doable) or code it yourself. In that case
all you need is use the unknown size in your segments above, and
adjust the timecode in the Clusters you send to that they are
continuous and contiguous (no gap). The easiest way would be to set an
unknown size on the Cluster too (excepted by a live stream reader
anyway) so you can recreate the Cluster timecode (as the value may not
fit in the size previously allocated). You have to know the last (end)
timecode in a Cluster when transitioning to a new Segment so you use
that for the new Cluster of the new Segment. That may require "deep
Block inspection" as you need to determine the duration of a frame
(especially for audio). Although sometimes the source file has that
duration for the last packet of each track.
--
Steve Lhomme
Matroska association Chairman
More information about the Matroska-users
mailing list