Re: How to concatenate segments?

jianwen chen <[email protected]>
Newsgroups gmane.comp.multimedia.matroska.user
Message-ID <[email protected]>
On Sun, May 15, 2011 at 5:17 AM, Steve Lhomme <[email protected]> wrote:

> On Fri, May 13, 2011 at 12:06 AM, jianwen chen
> <[email protected]> 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, thanks.
According to the code and the Matroska specification, we know a live stream
is designated by setting the “Segment” size to “unknown”.  I set the size to
a very large value and setting the duration of the video to 100 hours. And I
also delete the “SeekHead” elements ) and “Cues” elements in 2 mkv files.  I
have no cluster in the webm files.

cat  1split-004-largesize-changeduration-removeseekhead-recues.webm
2split-001-large-chaduration-rmseek-rmcue.webm > aaa.webm

But the file aaa.webm can only be played for the 1st segment.

What I want to do is concatenate the 2 segments together as a file and the
file can be played one segment by one segment.
Is there anything wrong above result in this?

The detailed info is followed:
File1
# mkvinfo 1split-004-largesize-changeduration-removeseekhead-recues.webm
+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ EBML maximum ID length: 4
|+ EBML maximum size length: 8
|+ Doc type: webm
|+ Doc type version: 2
|+ Doc type read version: 2
+ Segment, size unknown
|+ EbmlVoid (size: 4045)
|+ Segment information
| + Timecode scale: 1000000
| + Muxing application: libebml v1.0.0 + libmatroska v1.0.0
| + Writing application: mkvmerge v4.0.0 ('The Stars were mine') built on
Jun 17 2010 18:47:20
| + Duration: 2766143.488s (768:22:23.488)
| + Date: Wed May 11 06:02:42 2011 UTC
| + Segment UID: 0xfb 0x46 0x6a 0x88 0x4f 0xab 0xd3 0x94 0xa1 0xfd 0xf6 0xa7
0xba 0x5d 0x60 0x35
|+ Segment tracks
| + A track
|  + Track number: 1
|  + Track UID: 1
|  + Track type: video
|  + Default flag: 0
|  + MinCache: 1
|  + Codec ID: V_VP8
|  + Default duration: 41.708ms (23.976 fps for a video track)
|  + Language: und
|  + Video track
|   + Pixel width: 640
|   + Pixel height: 360
|   + Display width: 640
|   + Display height: 360
| + A track
|  + Track number: 2
|  + Track UID: 2
|  + Track type: audio
|  + Default flag: 0
|  + Codec ID: A_VORBIS
|  + CodecPrivate, length 4189
|  + Language: und
|  + Audio track
|   + Sampling frequency: 44100
|   + Channels: 2
|+ EbmlVoid (size: 1081)
|+ Cluster

File2
$ mkvinfo 2split-001-large-chaduration-rmseek-rmcue.webm
+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ EBML maximum ID length: 4
|+ EBML maximum size length: 8
|+ Doc type: webm
|+ Doc type version: 2
|+ Doc type read version: 2
+ Segment, size unknown
|+ EbmlVoid (size: 4045)
|+ Segment information
| + Timecode scale: 1000000
| + Muxing application: libebml v1.0.0 + libmatroska v1.0.0
| + Writing application: mkvmerge v4.0.0 ('The Stars were mine') built on
Jun 17 2010 18:47:20
| + Duration: 8585740.288s (2384:55:40.288)
| + Date: Wed May 11 06:09:38 2011 UTC
| + Segment UID: 0x12 0xea 0xf1 0x7f 0xb0 0x17 0x15 0x97 0xfb 0x67 0xd7 0x7b
0x91 0x28 0x2d 0xa3
|+ Segment tracks
| + A track
|  + Track number: 1
|  + Track UID: 1
|  + Track type: video
|  + Default flag: 0
|  + MinCache: 1
|  + Codec ID: V_VP8
|  + Default duration: 41.708ms (23.976 fps for a video track)
|  + Language: und
|  + Video track
|   + Pixel width: 640
|   + Pixel height: 360
|   + Display width: 640
|   + Display height: 360
| + A track
|  + Track number: 2
|  + Track UID: 2
|  + Track type: audio
|  + Default flag: 0
|  + Codec ID: A_VORBIS
|  + CodecPrivate, length 4189
|  + Language: und
|  + Audio track
|   + Sampling frequency: 44100
|   + Channels: 2
|+ EbmlVoid (size: 1081)
|+ Cluster


By the way, I find, if I just
 cat 1file 2 file > test.webm
without any modification of the original mkv files, the test webm file can
be played well by vlc, but can not played correctly by Mplayer.



Thanks,
Jianwen






> --
> Steve Lhomme
> Matroska association Chairman
> _______________________________________________
> 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
>

_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.