Hi. I recommend avformat_seek_file() in avformat/util.c, because this function use new semantics of various demuxer. And u will reference av_seek_frame_generic().
Internally, AVSEEK_FLAG_BACKWARD flag use AVFormatContext->streams[idxVideo]->nb_index_entries. BTW, some container have not this indexes. If this case, u can use AVSEEK_FLAG_BACKWARD and sequenced searching method. GL~~ -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Mediasystems GmbH Sent: Wednesday, July 01, 2009 2:57 AM To: 'Libav* user questions and discussions' Subject: Re: [libav-user] Frame accurate seeking on H.264 video streams Right, exactly that way I tried it. However, I assumed that av_seek_frame with flag AVSEEK_FLAG_BACKWARD set should seek to the previous I-frame. Am I wrong here? If av_seek_frame doesn't work like I thought, is there another libav function to achieve this? On Jun 26, 2009, at 10:57 AM, Mediasystems GmbH wrote: > Hello, > > I use ffmpeg for about one year with MPEG-2 streams. Everything > works fine > so far. Now I want to use H.264 coded videos as well. I'm trying to > do a > frame accurate random seeking on H.264 video streams. But I cannot > accomplish to decode all single frames without any artefacts after > calling > av_seek_frame. If I go through the stream from the beginning, it > works. Is > it generally possible to do frame accurate seeking on H.264 video > streams > and how? I think for this you need to seek to an I-frame, as H.264 is a progressive encoder, and some of the frames only contain the changes from the last frame to the current one. Once you have the previous I- frame, you can then keep grabbing and decoding frames until you reach the desired frame. This is how I was able to implement frame seeking in one of my simple projects from a while ago. > > Code snippet: > > ret = av_seek_frame(pFormatCtx, videoStreamIndex, timestamp, > AVSEEK_FLAG_BACKWARD); avcodec_flush_buffers(pCodecCtx); > > ... > while (av_read_frame(pFormatCtx, pPacket) >= 0) { ... > bytesDecoded = avcodec_decode_video(pCodecCtx, pFrame, ref > frameFinished, packet.data, packet.size); ... > > > Any help would be appreciated! > Many thanks. _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
