[Live-devel] H264 Headers in live stream

Ross Finlayson finlayson at live555.com
Thu Jun 25 16:43:02 PDT 2009


>I am trying to connect multiple clients to a live H264 stream from a file
>source. I have set the resuseFirstSource flag to be true to enable all the
>clients to render the same data. I could always connect the first client,
>but the subsequent clients on VLC always give a warning message called
>"Waiting for PPS/SPS unit"
>
>I appended the original ES file to itself to increase the file size. And I
>found that all the clients begin to render the stream when the first file
>ends and the fie restarts. This leads me to a conclusion that there is some
>header packaging missing in the H264 framer which does not allow random
>clients to join a live H264 stream.


Here's the problem:

There are special PPS/SPS NAL units at the start of your file (and 
nowhere else in the file).  Because you are treating your file as a 
live source ("reuseFirstSource = True"), only the first client will 
get to see these special NAL units; subsequent clients will not. 
Unfortunately, these special NAL units are necessary in order for VLC 
(and other decoders) to properly deode the stream.  Therefore, the 
server needs a way to deliver these special NAL units to all clients 
- not just those that happen to receive the data that was at the 
start of the file.

The standard solution to this problem is for the RTSP server to 
include the data for these special PPS/SPS NAL units in the SDP 
description that gets returned in response to a RTSP "DESCRIBE" 
command.  (This is done in a "a=fmtp:" line, using the 
"sprop-parameter-sets" parameter.)

Fortunately, our server implementation does this automatically, 
*provided that* you pass an appropriate "sprop_parameter_sets_str" 
parameter to "H264VideoRTPSink::createNew()".  In particular, this 
"sprop_parameter_sets_str" should be the Base64-encoded strings for 
the PPS and SPS NAL units, separated by a comma (',') character.

I.e., in your "ServerMediaSubsession" subclass - where you create 
your "H264VideoRTPSink" (in your implementation of the 
"createNewRTPSink()" virtual function), you will need to first read, 
and Base64-encode the PPS and SPS NAL units from the front of the 
file.

-- 

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


More information about the live-devel mailing list