[FFmpeg-user] Problem on MXF file seeking

肖波 13760746839 at 163.com
Wed Dec 7 04:51:01 CET 2011

I have some video clips,and I needed to decode them and capture frames start at a setted position.My standard step as follows:
1. ...(open video stream)
2.av_seek_frame(pFormatCtx, streamindex_video, start_position, AVSEEK_FLAG_BACKWARD);
3.av_read_frame(pFormatCtx, &packet),if return value<0 goto step 5;
4.if packet.stream_index == streamindex_video, avcodec_decode_video2(...); if packet.dts>start_position then process the frame.
If I didn't call step 2, the last frame's DTS values is 759.
With these steps, I found in step 2, if I seek to different position, the last frame's DTS value is different.And so most of the time,it's not equal to 759.
If I set the parameter stream_index in av_seek_frame() to -1,the last frame's packet.dts value is always equal to 759. Butit will cost a lot of time to seek if the position is a large number.
I tested this with MPEG2 and WMV files,it's all OK.
Anybody know the reason? And how can I  know the real frame number after av_seek_frame()?
For example,one of my video clip with duration of 759 frames,and if I decode from the first frame,
I wanted to get all frames of a video start at a set position,but after I called the av_seek_frame function,and when I call the av_read_frame function

More information about the ffmpeg-user mailing list