[Libav-user] newbie question: what is the appropriate/best way to obtain frame_rate from a video and how to control it when decoding video?
chisholm at mitre.org
Tue Dec 20 18:25:26 CET 2011
Well if you are reading from a file, you control the rate at which you
read. So you could stick a pause for say, 100ms somewhere, to throttle
yourself back to 10fps. If you are reading from a network stream going
at full speed, you'll have to drop some frames. You can't play it in
slow-motion, since that would require keeping a potentially infinitely
growing buffer of backlogged frames. So it will require some creativity
to know when to drop and when to keep, to get approximately the correct
framerate. This stackoverflow post gave me some inspiration, when I was
thinking about this:
On 12/19/2011 8:11 PM, Yingzhou Zhang wrote:
> Thanks for your reply.By "control frame rate" I meant,say,the video file
> itself is 25fps, and I wanna play the video with the speed of 10frame/s.
> 2011/12/20 Michael Chisholm<chisholm at mitre.org>
>> I've struggled myself with this. There are a lot more framerate-related
>> fields than that lying around. The ones I know of (in ffmpeg 0.6.3) are
>> (stream=AVStream, cc=AVCodecContext):
>> (you'd think you could maybe derive framerate from the last) I am no
>> expert, but my guess is that not all containers contain a framerate field
>> somewhere for tools to read. So libav* tries to estimate one from timing
>> information. E.g. in my app I can read from a udp multicast network
>> stream, and even for the same stream, each time I run the app, it shows a
>> slightly different framerate (as shown by dump_format). Maybe because it
>> sees a different subsequence of timestamps, or the relative distribution in
>> time of those timestamps might be slightly different, ... I don't know. In
>> my app, I settled on stream->avg_frame_rate for my purposes.
>> As far as controlling it, I'm not sure what you mean... did you just want
>> to decode at the frame rate of the stream, or somehow manipulate the the
>> video to change its framerate?
>> On 12/19/2011 1:25 AM, Yingzhou Zhang wrote:
>>> hey there.
>>> I have googled a little bit,found 2 way
>>> 2:AVCodecContext-> streams->r_frame_rate?
>>> However the output of the 2 ways are not the same??
>>> Could you tell me what is the exact way to get frame_rate and how to
>>> control it when decoding video?
>>> Thanks a lot
>>> Libav-user mailing list
>>> Libav-user at ffmpeg.org
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
> Libav-user mailing list
> Libav-user at ffmpeg.org
More information about the Libav-user