[Live-devel] Layered video with Live555
Ross Finlayson
finlayson at live555.com
Sun Mar 4 04:12:28 PST 2007
>Ok, I think I have the StreamFramer class basically working except for
>one small problem. To parse the file, I created a subclass of
>MPEGVideoStreamParser (purely out of convenience), and defined a parse()
>routine that has two states: PARSING_START_SEQUENCE and
>PARSING_NAL_UNIT. The parser basically alternates between these two
>states either throwing data out (to find the first sequence), or saving
>it (until it finds the next).
>
>So naturally, there is no start sequence at the end of the file. It
>just sorta ends. So what I'm seeing when I play from my Framer source
>class to a H264VideoFileSink class is that all the NAL units are copied
>over to the output file except the last one.
> What I think is happening is, for the last NAL unit, my call to
>test4Bytes() is throwing an exception once it gets to the end of the
>file .. causing parse() to return 0. Meanwhile, the StreamParser class
>goes off and tries to read more from the file, sees that the file is at
>EOF, and closes the file, etc.
Yes. Unfortunately, the current stream parsing code discards
already-read data once it encounters the end of the input file.
There are probably ways to work around this (e.g., pass some function
other than "FramedSource::handleClosure" to the parent constructor
when constructing "MPEGVideoStreamParser"), but it would be messy.
Instead, I suggest just ignoring the issue if you can. (Is the very
last NAL unit in each file really important to get?) If you can't
ignore it, then you could also work around the problem by appending a
'start code' to the end of each file, before you start reading it.
By the way, the *real* difficulty that you're going to face in
writing your "H264VideoStreamFramer" subclass is computing proper
presentation times and durations (the "fPresentationTime" and
"fDurationInMicroseconds" member variables) for each NAL unit. (This
has tripped up other people who have tried streaming H.264 video from
a file.)
--
Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
More information about the live-devel
mailing list