<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<div id="signature">
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">
<pre>Many thanks for the response, Ross.<br /><br />You wrote<br />>> The only important thing to note here is that the “fPresentationTime”s need to correspond to the times that you’d get by calling <br />>> “gettimeofday()” - i.e., you can’t use your own clock with completely different values to set the “fPresentationTime”s. <br />>> (The reason for this is that our code - when computing ‘wall clock’ times for outgoing RTCP “SR” packets - uses “gettimeofday()”.)
</pre>
</div>
</div>
<p>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?</p>
<p>You also wrote</p>
<p>><em> Do I need to add logic to give SPS and PPS frames the same timestamp as the corresponding video frames? </em></p>
<p>>> I’m not sure how important this is; it depends on whether or not decoders care about this.</p>
<p>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.</p>
<p>This seems very complicated compared to just calling gettimeofday() every frame, am I missing something here?</p>
<p>Regards</p>
<p>David</p>
<pre><br /><span style="font-family: courier new, courier, monospace;">
</span></pre>
<p id="reply-intro">On 2021-07-29 9:57 am, DJM-Avalesta wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div id="replybody1">
<div style="font-size: 10pt; font-family: Verdana,Geneva,sans-serif;">
<p>Hi,</p>
<p>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.</p>
<p>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.</p>
<p>I am simply using gettimeofday() for every frame eg.</p>
<p> g<em>ettimeofday(&fPresentationTime, NULL);</em></p>
<div id="v1signature">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.</div>
<div> </div>
<div>I could replace gettimeofday with something like this, but is this valid?</div>
<div>
<pre> 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;
}
</pre>
</div>
<div>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.</div>
<div> </div>
<div>Do I need to add logic to give SPS and PPS frames the same timestamp as the corresponding video frames?</div>
<div> </div>
<div>Many thanks</div>
<div>David</div>
</div>
</div>
</blockquote>
</body></html>