[Libav-user] a question for av_seek_frame

Safi ud Din Khan safiuddinkhan at gmail.com
Mon Dec 9 07:24:15 CET 2013


refer to this if u wanna understand what really keyframe is
http://en.wikipedia.org/wiki/Video_compression_picture_types



also do remember it was also quiet confusing for me av_seek_frame seek 
stream by DTS (Decode Time Stamp) and not by PTS (Presentation Time 
Stamp) so when you seek you are'nt going get to the accurate position of 
the stream

On 12/09/2013 09:29 AM, YIRAN LI wrote:
> And I have another question: If an AVPacket object has AV_PKT_FLAG_KEY 
> bit set in flags, does that mean this packet when passed into 
> avcodec_decode_video2 can always get a complete frame (I mean by 
> calling avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, 
> &packet) the 3rd argument set to true)?
>
> Thanks
>
>
> 2013/12/9 YIRAN LI <mrfun.china at gmail.com <mailto:mrfun.china at gmail.com>>
>
>     Thanks Don,
>
>     So in order to get a correct image, I must not use AVSEEK_FLAG_ANY
>     so that av_seek_frame by default will seek to a key frame. And I
>     should continue to read from that point and decode until I get a
>     frame with the timestamp I want.
>
>     Do you know if all demuxers can support av_seek_frame() correctly
>     so that as long as there's a key frame before the position I pass
>     to the function, they all can correctly seek to that key frame?
>
>     Thanks
>
>
>     2013/12/4 Don Moir <donmoir at comcast.net <mailto:donmoir at comcast.net>>
>
>         >----- Original Message -----
>         >From: YIRAN LI
>         >To: This list is about using libavcodec, libavformat,
>         libavutil,libavdevice and libavfilter.
>         >Sent: Sunday, December 08, 2013 9:44 PM
>         >Subject: [Libav-user] a question for av_seek_frame
>         >Hi friends
>         >Here I have a question about av_seek_frame.
>         >For example if I have a video stream of time stamps 0, 1, 2,
>         3, 4, 5, 6, 7, 8, 9, 10. and only frame at 0 is a key frame.
>         >if I call av_seek_frame(x,x,5, AVSEEK_FLAG_BACKWARD |
>         AVSEEK_FLAG_ANY) and then av_read_frame, the first frame I get
>         will be frame 6, is this correct?
>         >then if I call av_seek_frame(x, x, 5, AVSEEK_FLAG_BACKWARD)
>         and then av_read_frame, then the first frame I get will be
>         frame 1, is this correct?
>         >and if both can seek to a frame and first one can get a frame
>         quicker, in what circumstance should I use the second one?
>         >Thanks
>         Non key frames require the previous key frame in order to be
>         decoded correctly. So if you skip past the key frame to frame
>         6, then the decoded image will most likely be incorrect.
>         While your first example may be quicker, it will not be
>         correct. Best to stay away from AVSEEK_FLAG_ANY for normal
>         display purposes. Proper seeking to frame 6 would require a
>         seek to frame 1 and then read and decode to frame 6.
>         AVSEEK_FLAG_ANY can be useful in some cases but generally not
>         for normal display.
>
>         _______________________________________________
>         Libav-user mailing list
>         Libav-user at ffmpeg.org <mailto:Libav-user at ffmpeg.org>
>         http://ffmpeg.org/mailman/listinfo/libav-user
>
>
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20131209/0b1e58a4/attachment.html>


More information about the Libav-user mailing list