Gary, See http://github.com/lbrandy/ffmpeg-fas/tree/master
This is a "frame-accurate seeking and frame-counting" library. I've certainly used parts of it in some of my programs and it seems to work quite well. It builds an index table by seeking forward to each keyframe, then you can give it a frame number and seek to the nearest, lower numbered keyframe and then step on from there (depending on the GOP size, that's not usually very far). Even if it doesn't do exactly what you want, it gives a good insight into what you need to do for accurately seeking. In my apps, I've modified it to write the table out in binary form, whereas the library at github writes it in plain text. I prefer to read tables in binary as I've never really trusted fscanf and its friends. Regards, Clive -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Smart, Gary Sent: 15 April 2009 22:30 To: [email protected] Subject: [libav-user] av_seek_frame AGAIN I have written a program to dump out all frame numbers and associated pts/dts values and key-frame statuses. This works fine. If I want to av_seek_frame back to a specific frame from the aforementioned dump, what timestamp value should the seek be based on? Is it the dts value or the pts value (neither of which gets me anywhere near the required frame)? Or is it the pts/dts minus the first pts/dts value in the file (which seems to get me close - but never spot on). When I seek, if I am seeking forward I use AVSEEK_FLAG_ANY, if I'm seeking backwards I use AVSEEK_FLAG_BACK | AVSEEK_FLAG_ANY. I know that the av_seek_frame can theoretically be used to locate ONLY KEY FRAMES (i.e. don't specify AVSEEK_FLAG_ANY) but in this mode, the returned packets may be more than one keyframe spacing away! I really want to be able to seek and get very close if not spot-on a particular frame in the file - but this seems impossible! Can anyone tell me how to compute a suitable seek value from a packet's pts/dts that will return me to a previously decoded frame? Gary Smart _______________________________________________ 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
