[Ffmpeg-devel] Re: Fwd: Is AVFrame->pts really set by libavcodec when

QuickTime ffmpeg
Wed Apr 18 14:09:30 CEST 2007


On 4/18/07, Luca  wrote:



> Hi all,
>
> according to the documentation in avcodec.h, the pts field in AVFrame
> (defined in FF_COMMON_FRAME) is set by libavcodec when decoding.
>
> But a simple test [*] showed that such field is not touched by
> libavcodec, or is set to 0 (depending on the codec), at least when
> decoding mpeg1/2 and raw video.
>
> Is this a bug in libavcodec, a bug in the documentation, or something
> else?
>
>                                Thanks,
>                                        Luca
>
> [*] To see it yourself, try adding a
>     fprintf(stderr, "PTS: %Ld\n", picture.pts);
> before and after avcodec_decode_video() in ffmpeg.c:output_packet().
> Then, run "./output_example test.mpg; ./ffmpeg -i test.mpg out.avi"
> The mpeg decoder seems to set pts to 0. The raw decoder (use test.y4m
> instead of test.mpg) does not touch the pts field.
>

You should set the flags:AVFMT_FLAG_GENPTS in AVFormatContext

    if(av_open_input_file(&ic,filename,NULL,0,NULL) < 0)
        return -1;
    ic->flags |= AVFMT_FLAG_GENPTS;
    if(av_find_stream_info(ic) < 0){
        ret = -1;
        goto return_pos;
    }

-- 
//----------------------------------------
Heaven is not a place, it's just a feeling




More information about the ffmpeg-devel mailing list