[Ffmpeg-devel] Seeking into MPEG TS video files
Mon Apr 2 14:19:32 CEST 2007
Thanks for your answer.
The problem is, that I'm only able to jump to the beginning of the file.
Reading older threads reagarding this problem I found this code:
av_seek_frame( fmtCtx, -1, TARGET_PTS, AVSEEK_FLAG_BACKWARD );
CodecCtx->hurry_up = 1;
av_read_frame( fmtCtx, &Packet );
// should really be checking that this is a video packet
MyPts = Packet.pts / Packet.duration *
AV_TIME_BASE / av_q2d( Stream->r_frame_rate);
if( MyPts > TARGET_PTS )
avcodec_decode_video( CodecCtx, pFrame, &gotFrame, Packet.data,
av_free_packet( &Packet );
CodecCtx->hurry_up = 0;
// Now near TARGET_PTS with Packet ready for decode (and free)
But after I have seek into my video file and call av_read_frame(), I always
get the first frame of the video. av_seek_frame() just seems to ignore the
timestamp argument. Only if the timestamp is bigger than the duration of the
stream, I get a packet with a negative PTS.
2007/4/2, M?ns Rullg?rd <mans at mansr.com>:
> Stefan Paulsen said:
> > Hi,
> > is there a way to seek into MPEG TS video files? Using av_seek_frame()
> > doesn't seem to work, because there are no information on where to find
> > keyframes. I'm only able to jump to the beginning.
> MPEG TS doesn't have an index, so seeking will always be problematic. You
> should still be able to seek to an approximate location if you don't care
> about landing at a keyframe.
> M?ns Rullg?rd
> mans at mansr.com
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
More information about the ffmpeg-devel