[Libav-user] I'll ask in other words - how can I force input frame rate?

wl2776 wl2776 at gmail.com
Mon Oct 10 09:26:52 CEST 2011

Steffen Ebersbach-2 wrote:
> Am 10.10.2011 08:54, schrieb wl2776:
>> Thank you for the answer, but you've misunderstood me. My problem is 
>> that functions avformat_open_input() and avformat_find_stream_info() 
>> incorrectly determine frame rate, incorrectly assign values to 
>> AVFormatContext/AVStream members (time_base, what else, I don't know) 
>> and, since that, av_read_frame returns frames having incorrect 
>> PTS/DTS. I tried using av_rescale_q() to recalculate timestamps, but 
>> the resulting value are like the following (dts, pts): (0, 0), (0, 0), 
>> (0, 0), (1, 1), (1, 1). And when I pass the last AVPacket, having pts 
>> = dts = 1, to the av_interleaved_write_frame(), it complains that 
>> "application has provided non-monotonically increasing timestamps". 
> You write that the timestamps of the mjpeg 
> frames are stored separately? That means libav don't see them? I think 
> his is the reason for the wrong entries in avstream/ Fomartcontext. In 
> this situation the best way i think, ist to manage the pts/dts values by 
> your self. for mpeg-ts 25fps the right pts are 3600, 7200, ... , because 
> the time_base is 90000 and the delay is 40 ms.
That's right, libav doesn't see timestamps, while my application does.
I'm already going that proposed way, by recalculating timestamps with

Now I see that I also can store that separate timestamps in a queue and
retrieve them in the main cycle: while (! exit_signaled) { av_read_frame();
... av_interleaved_write_frame(); }

However, the avformat_find_stream_info() function also reads some data and
analyzes the stream basing on them.
I use the results of that analysis to fill the members of output
AVFormatContext/AVStream with avcodec_copy_context() and av_metadata_copy();

And I'm unable here to control timestamps, which avformat_find_stream_info()
consumes as it is completely opaque to my app.

Therefore I'd like to deliver to libav in the very beginning all the
information, my application possesses.

View this message in context: http://libav-users.943685.n4.nabble.com/How-can-I-emulate-r-switch-programmatically-tp3874115p3889399.html
Sent from the libav-users mailing list archive at Nabble.com.

More information about the Libav-user mailing list