[Ffmpeg-devel] av_seek_frame() units

Steve Willis ffmpeg
Wed Jul 6 15:27:42 CEST 2005


Just so everyone is on the same page, would someone please post some 
sample code for a concrete example? Like Ian, I'm not really clear on 
how the AVStream.time_base units work...are some streams based on 
seconds, and others based on ms?

Let's say I want to seek to a frame that is 14.25 seconds into a stream. 
Would someone please post actual code showing (1) how to calculate the 
value for 14.25 seconds to pass to av_seek_frame to seek to the nearest 
key frame (Ian's question), and (2) a recommended way to actually seek 
to the precise frame for 14.25 seconds, regardless of whether it is a 
keyframe (my question).

Ian and I both need help understanding how to convert a real time value 
(in seconds, ms, whatever) into AVStream.time_base units. I need some 
extra help on refining the call to av_seek_frame to produce the exact 
frame for a time, because my program is for scientific video analysis, 
and I need a way to let users step forward and backward through frames, 
as well as seek to exact time values to match data (the nearest key 
frame might not show the correct sample point.) The suggestions to 
enable hurry_up mode have not been ignored...I'm just struggling to 
understand and implement them being new to the library and the language 
(I'm binding this to a larger Java application.) I've got the rest of 
the more routine video player stuff working and am just trying to work 
past this last sticking point.

Thank you for all your help!

Steve


Andy Parkins wrote:
> On Wednesday 2005 July 06 07:10, Ian Gowen wrote:
> 
> 
>>Thus, time = frame_number / frame_rate. However, what I don't understand is
>>how to put that into AVStream.time_base units, as the docs say to do. Do I
>>multiply it by
>>the time_base? Divide? I don't get it, and I'm pretty sure this is
>>where I'm screwing
>>up.
> 
> 
> I'm not sure why you would need to do this.  What source for frame_number are 
> you using - it's not in any of the AV structures.  If you want the time 
> simply read Packet.pts; why calculate it when it's already there?
> 
> If you are trying to seek, you would want to seek a time anyway.  Maybe a 
> percentage through the file?  ffplay does this like this:
> 
> seekPoint = (int64_t)(formatContext->start_time+frac*formatContext->duration);
> 
> 
> 
> 
> Andy
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/ffmpeg-devel





More information about the ffmpeg-devel mailing list