[Ffmpeg-devel] av_seek_frame problem

tenze at libero.it tenze
Tue Oct 24 10:37:54 CEST 2006

Hi all,

I am trying to use the ffmpeg (libavcodec and avformat) in order to read a given block of mpeg videos. I followed the tutorial of Martin Boehme, and all seem to work fine. Now I am trying to add a call to av_seek_frame() function in order to start play from a given point (timestamp) but it does not work. The av_seek_frame is correctly called (return value is ok), but the video decoding starts always from the first frame of the file even when I use a timestamp greater than 0.

May you help me?

I send a part of my code:
// Assign appropriate parts of buffer to image planes in pFrameRGB
    avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
        pCodecCtx->width, pCodecCtx->height);

                // Here I set the position given by the argv[2]
                if (argc==3){
                        int64_t timestamp=atoll(argv[2]);//*AV_TIME_BASE;
                        // add the stream start time
                        if (pFormatCtx->start_time != AV_NOPTS_VALUE)
                                timestamp += pFormatCtx->start_time;
                        ret = av_seek_frame(pFormatCtx, -1, timestamp, AVSEEK_FL
                        if (ret < 0) {
                                fprintf(stderr, "%s: could not seek to position
                                argv[1], (double)timestamp / AV_TIME_BASE);
;// Read frames and save first five frames to disk
    while(av_read_frame(pFormatCtx, &packet)>=0)
        // Is this a packet from the video stream?


Perdi 2 Taglie in 60 Giorni con Perdi Peso Cerotto! Clicca qui sotto

More information about the ffmpeg-devel mailing list