[Ffmpeg-devel] Timestamps on Decoding

Ronald S. Bultje rbultje
Mon Oct 24 03:02:37 CEST 2005


On Sun, 2005-10-23 at 18:45 -0400, Paul Curtis wrote:
> But the last question was never answered: when I receive a complete raw 
> frame, how can I accurately tell what it is I have received? Queueing 
> the frames (audio or video) and presenting them to the Helix encoder 
> wouldn't be a problem IF I could determine when the frame SHOULD be 
> presented. This is the crux of the problem, and even Richard has said 
> it's a problem.

Depends on how you call av_decode_video(). I call it in a loop, like
this (quasi-code):

for (;;) {
  if (output = av_decode_video (ctx, input)) {
    // do something with output
  }
}

1) if it's an I frame, then output == input, roughly. Timestamps, all
are the same. In addition, if ctx->has_b_frames is false, then output ==
input also. In any case, output.PTS == input.PTS.
2) if neither of the above applies, then you probably have a
backward-reference frame, so output may well represent a frame that you
fed to the decoder earlier. You'll need to do PTS-calculationing, like I
showed you in my first email (but there's other reasonable ways to do
it, also).

Does this make sense?

Cheers,
Ronald





More information about the ffmpeg-devel mailing list