[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
AG_ANY);
if (ret < 0) {
fprintf(stderr, "%s: could not seek to position
%0.3f\n",
argv[1], (double)timestamp / AV_TIME_BASE);
}
}
//avcodec_flush_buffers(pFormatCtx->streams[videoStream]->codec)
;// Read frames and save first five frames to disk
i=0;
while(av_read_frame(pFormatCtx, &packet)>=0)
{
// Is this a packet from the video stream?
if(packet.stream_index==videoStream)
{
[...]
}
[...]
}
***********************************
------------------------------------------------------
Perdi 2 Taglie in 60 Giorni con Perdi Peso Cerotto! Clicca qui sotto
http://click.libero.it/webnation24ott
More information about the ffmpeg-devel
mailing list