[Live-devel] H264 RTP stream recording to AVI

Ross Finlayson finlayson at live555.com
Mon Jan 9 01:36:25 PST 2017


>> But if you *really* don’t have a RTSP server, then you’ll need to
>> find/figure out the SPS and PPS H.264 NAL units for the stream, and
>> pass them to the "H264VideoFileSink::createNew()” function.  Or,
>> prepend those NAL units to the H.264 video stream, if you want to do something else with it.
>> 
> We won't have an RTSP server providing this information however I am expecting to receive multicast SAP/SDP packets which should in theory hold this information

Yes, it will.  The SAP packets[*] should contain a SDP description that describes the multicast RTP/RTCP stream.  This SDP description will give you what you need.  Specifically, you would:
1/ Create a “MediaSession” object by calling 
	MediaSession::createNew()
passing the SDP description as a (string) parameter.
2/ Then iterate over each ‘subsession’ (i.e., audio, video, etc.) of this “MediaSession” object, and for each ‘subsession’ (i.e., of type “MediaSubsession”):
	2a/ Call “MediaSubsession::initiate()” on it.
This will create appropriate “RTPSource” (and “RTCPInstance”) objects that you can then receive data from in the usual way - i.e., by calling “getNextFrame()”.

In particular, you can create a “AVIFileSink” from the “MediaSession” object, and then call “startPlaying()” on the “AVIFileSink” object.  This should cause the input data to be written to your AVI file.

For an example of code that does steps 1/, 2/, and 2a/, look at the code for our “testRTSPClient” application (in the “testProgs” directory).  Or, alternatively, the code (“playCommon.cpp”) for our “openRTSP” application.  Of course, these applications also do other things - i.e., send RTSP commands - in order to get the SDP description, but you won’t be needing to do that.


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

[*] Note that we also have a demo application (in “testProgs”) called “sapWatch” that you can use to receive/print the incoming SAP packets.





More information about the live-devel mailing list