[Ffmpeg-devel] Timestamps on Decoding

Paul Curtis pfc
Sun Oct 23 23:10:21 CEST 2005


Rich Felker wrote:

> I'm getting the feeling Paul doesn't know much about what he's talking
> about when it comes to frame order.. :(

I don't, and I never claimed to. However, I have asked here several 
times how to accomplish what I need. I've gotten some good suggestions, 
and quite a few abrupt and less than helpful answers.

I have learned a lot about MPEG2 video while building tools, but I 
certainly am no expert. In the pseudo-code snippet below, please, Mr. 
Felker, SHOW ME how to determine the frame type and PTS. The basics for 
this code were adapted from 'ffmpeg.c', with the exception of the use of 
DTS.

While I've heard a lot of reasons why what I'm doing (using DTS) is 
incorrect, I have yet to see a concrete answer on how to do it correctly.

Paul



     for (;;) {

        if (av_read_frame(ic, &pkt) < 0)
           break;

        frame_size_in = pkt.size;
        rawData = pkt.data;

        if (pkt.stream_index == audioIndex) {
           samples = av_fast_realloc(samples, &samples_size, 
FFMAX(pkt.size, AVCODEC_MAX_AUDIO_FRAME_SIZE));
           ret = avcodec_decode_audio(audioCodecCtx, samples, 
&audio_samples_out, rawData, frame_size_in);
           audioStart = ic->streams[audioIndex]->cur_dts;
           audioEnd = [ calculate based on frame rate, etc. ]
           [ do something with the raw frame ]
        }

        if (pkt.stream_index == videoIndex) {
           do {
              ret = avcodec_decode_video(videoCodecCtx, &frame, 
&finished, rawData, frame_size_in);
              if (finished) {
                 videoStart = ic->streams[videoIndex]->cur_dts;
                 videoEnd = [ calculate based on frame rate, etc. ]
                 [ do something with the raw frame ]
              }
              rawData += ret;
              frame_size_in -= ret;
           } while (frame_size_in > 0);
        }
        av_free_packet(&pkt);

     }





More information about the ffmpeg-devel mailing list