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