[Live-devel] fPresentationTime fDurationInMicroseconds value setup

Tao Wu lanlantao at gmail.com
Thu Jan 28 09:38:28 PST 2010


Hi Ross,

Thanks for your explanations. I am somehow unsure about the proper setup of
fPresentationTime and fDurationInMicroseconds.
My h264 video stream comes  in the oder of pps, sps, I, P, P, P...(29 times)
in a second.
Is the following code correct ? Thank you.

::continueReadProcessing() {

  ......
  if (acquiredFrameSize > 0 ) {
      // We were able to acquire a frame from the input.
      // It has already been copied to the reader's space.
        fFrameSize = acquiredFrameSize;
        fNumTruncatedBytes = 0;

        seq++;

     // Compute "fPresentationTime"
        if ( the frame != pps or sps ) // regular video frames
             fPresentationTime.tv_usec += (long) 33*1000;
        else  // pps or sps , presentation time does not change
             ;

        while (fPresentationTime.tv_usec >= 1000000) {
            fPresentationTime.tv_usec -= 1000000;
            ++fPresentationTime.tv_sec;
        }

        if ( the frame != pps or sps ) // regular video frames
              fDurationInMicroseconds = (long) 33*1000;
        else  // pps or sps , duration is 0
               fDurationInMicroseconds = 0;

        // Call our own 'after getting' function.  Because we're not a
'leaf'
        // source, we can call this directly, without risking infinite
recursion.
        afterGetting(this);
    }
 .....................

}

>I need to understand the value of fPresentationTime
>fDurationInMicroseconds. Those two are used in almost all
>videoframers.
>I have an IP camera, which sends out video frames in the oder of
>pps, sps, I, P, P, P...(29 times) in a second.  So should the
>fPresentationTime/ fDurationInMicroseconds be set as 1000/32
>(including both pps ,sps and vidoe frames) ms or 1000/30 (only the
>video frames) ms?

Note that "fPresentationTime" and "fDurationInMicroseconds" are
separate variables, and both should be set (although, if you know
that your framer will always be reading from a live source (rather
than a file), you can probably omit setting
"fDurationInMicroseconds").

(Note: Because you mention "PPS" and "SPS", I assume that you're
referring specifically to H.264 video.)

"fDurationInMicroseconds" should be set to 1000000/framerate  for the
NAL unit that ends a video frame (Note: This will be the NAL unit for
which your reimplemented "currentNALUnitEndsAccessUnit(
)" virtual
function will return True), and should be set to 0 for all other NAL
units.

Similarly, all NAL units that make up a single video frame (including
any PPS and SPS NAL units) should be given the same
"fPresentationTime" value (i.e., the presentation time of the video
frame).

>It looks the framer put several video frames in a single RTP packet.

No, it's the "H264VideoRTPSink" class (i.e., our implementation of
the RTP payload format for H.264) that takes care of packing NAL
units into RTP packets.  You don't need to know or care about this.
Just feed the "H264VideoRTPSink" one NAL unit at a time.
--

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20100128/2f01ad75/attachment.html>


More information about the live-devel mailing list