[Live-devel] Stream FFMPEG packets using subclassed OnDemandServerMediaSubsession

Ross Finlayson finlayson at live555.com
Tue Feb 25 12:24:50 PST 2020



> On Feb 26, 2020, at 8:49 AM, Matthew Czarnek <mczarnek at edge360.com> wrote:
> 
> I need to be able to have trick play over RTSP for Matroska files.

Note that when streaming from a Matroska file, ’seeking’ should already work; just not fast-forward or reverse play.


> it is streaming it to openRTSP and storing it to a file

This is good.  Many people don’t even get this far :-)


> However, I cannot get that file to play.
> 
> I suspect it has something to do with the NAL start codes. Primarily because VLC's error log is telling me: h264 module discarded (no startcode)

This is strange, because “openRTSP” records H.264 streams by using a “H264VideoFileSink” object, which automatically inserts a ’start code’ (0x00000001) before each NAL unit in the file.  (Note that the incoming H.264/RTP data does not include start codes.)

Be sure that you rename the video file - recorded by “openRTSP” - to have a “.h264” filename suffix before you try playing it with VLC.  Otherwise VLC probably won’t recognize it.


> I've looked at the bytes of the AVPacket, every packet does seem to have the first few bytes used for a NAL Unit Header. I've tried cutting those off, thinking they were the start codes

No!  The start code is 4 bytes: 0x00 0x00 0x00 0x01 (or sometimes 3 bytes: 0x00 0x00 0x01)


> I've tried creating H264VideoStreamDiscreteFramer with includeStartCodeInOutput set to true.

No, when streaming over RTP, that is never the right thing to do.

Your “createNewRTPSink()” implementation should be creating a “H264VideoRTPSink”.

Your “createNewStreamSource()” implementation depends upon your H.264 video source.  If it is a continuous byte stream (which is what “ffmpeg” usually generates when encoding H.264), then you should use a “H264VideoStreamFramer”.  If, however, it is discrete H.264 NAL units, then you should use a “H24VideoStreamDiscreteFramer”.  Your input source should feed H.264 NAL units - one at a time - to the downstream “H24VideoStreamDiscreteFramer” object.  These NAL units *must not* begin with a ‘start code’ (nor should you set the “includeStartCodeInOutput” parameter in the “H24VideoStreamDiscreteFramer”).


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/




More information about the live-devel mailing list