[Libav-user] How to corretly setting container and stream information when using an external encoder and using libavformat to pack the movie container

Ingmar Rieger dev at irieger.net
Sat Oct 26 15:13:51 EEST 2019


On 26.10.19 10:59, Carl Eugen Hoyos wrote:
> That's at least a surprising argumentation given the number of encoders
> included in FFmpeg.
Did I miss something? For me the relevant codecs I know for intermediate 
work are ProRes, DNxHR and Cineform with the later being seldomly used 
but the only open standard and as I recently found out supported in 
Resolve for some time now so as my main target is Resolve it seems worth 
giving it a try. ProRes and DNxHR are both proprietary with only reverse 
engineered codecs available.

>>    - Bit rate is just the value from one sample and depends very much on
>> the input resolution, I think the value is from a 4K sample file. Does
>> this really matter? The value reported from "ffmpeg -i testout.mov" is
>> completely different anyway, I assume it is calculated when calling
>> "av_write_trailer"?
> And is the written value correct?
Looking at my example with just below 800 KB per frame and 5 frames 
written (at 120fps) and calculating it it makes sense. Also after retime 
without reencoding to 5 fps it matches the file size. Was just wondering 
if this is something one has to take care of or if it will be done by 
libav based on actual data?

>> 2. Correct frame rate/time base settings. Tried several examples, tried
>> replicating what I extracted from them and made of the documentation
>> regarding libav I found about this topic but as the link below (ffmpeg
>> -i output) shows, the framerate is always wrong. Had combinations of
>> parameters where I had clips with 16k fps etc.
> You have to read back the actual timebase used by the muxer (can
> be different than the one you requested) and calculate the timestamps
> accordingly.
Is there a good introduction how to correctly set time bases and 
calculate frame numbers/timecodes from it?

Whatever I change I get different frame rates but never what I intend 
like in this example 24fps. (This shall be variable later on but would 
be nice to at least understand it)

So basically I have an input like frame_rate (in integer for simplicity, 
don't care about the crazy 23.98 and other strange rates), a frame 
number from 0 to NUM_FRAMES-1 and ideally a start time input -> How to 
set the correct time base/rates and calculate the frame dts/pts?

Kind regards,

More information about the Libav-user mailing list