[Live-devel] RTP presentation times

DJM-Avalesta david.myers at avalesta.com
Thu Jul 29 07:21:12 PDT 2021


Many thanks for the response, Ross.

You wrote
>> The only important thing to note here is that the "fPresentationTime"s 
>> need to correspond to the times that you'd get by calling
>> "gettimeofday()" - i.e., you can't use your own clock with completely 
>> different values to set the "fPresentationTime"s.
>> (The reason for this is that our code - when computing 'wall clock' 
>> times for outgoing RTCP "SR" packets - uses "gettimeofday()".)

Just to clarify, by "needs to correspond", do you mean the format of the 
time within fPresentationTime here? So as long as I call gettimeofday 
once at the start of the stream and increment it as a struct timeval, as 
shown below, am I ok?

You also wrote

> _ Do I need to add logic to give SPS and PPS frames the same timestamp 
> as the corresponding video frames? _

>>  I'm not sure how important this is; it depends on whether or not 
>> decoders care about this.

On an i-frame my StreamSource::deliverFrame() function gets called 3 
times, ie for the SPS frame, the PPS frame and for the video data. I 
could advance the presentation time for the SPS frame and not for the 
PPS and video, as long as I can count on the frames always being in this 
order. On a p-frame, I just need to advance the presentation time.

This seems very complicated compared to just calling gettimeofday() 
every frame, am I missing something here?

Regards

David

On 2021-07-29 9:57 am, DJM-Avalesta wrote:

> Hi,
> 
> My video encoder/server takes a PAL TV input, h.264 encodes it, and 
> streams it out on an  RTP multicast stream to a decoder.
> 
> I am finding that the decoder output is somewhat erratic and not 
> decoding smoothly when compared to the original input to the encoder. 
> The decoder (3rd party) is blaming the RTP presentation times it is 
> receiving in the encoded stream.
> 
> I am simply using gettimeofday() for every frame  eg.
> 
> g_ettimeofday(&fPresentationTime, NULL);_
> 
> Other encoders and IP cameras seem to have perfectly sequenced 
> presentation times so, for a 25fps stream, each frame has a 
> presentation time of exactly 40ms later than the previous frame, 
> whereas my stream varies from 27ms to 42ms or worse.
> 
> I could replace gettimeofday with something like this, but is this 
> valid?
> 
> if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0)
> gettimeofday(&fPresentationTime, NULL);
> else
> {
> // Increment by the sample time
> unsigned uSeconds = fPresentationTime.tv_usec + 1000000/25; //25fps, 
> the frame rate
> fPresentationTime.tv_sec += uSeconds/1000000;
> fPresentationTime.tv_usec = uSeconds%1000000;
> }
> 
> Also, other encoders seem to have the same timestamp for the SPS and 
> PPS frames as for the corresponding video frames, whereas my encoder 
> has individual timestamps on the SPS and PPS packets, which are 
> different from the video frames timestamps.
> 
> Do I need to add logic to give SPS and PPS frames the same timestamp as 
> the corresponding video frames?
> 
> Many thanks
> David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20210729/1c638576/attachment.htm>


More information about the live-devel mailing list