[FFmpeg-devel] [PATCH V1 0/2] Use avctx->framerate first for frame rate setting

Gyan ffmpeg at gyani.pro
Sun Apr 28 12:29:41 EEST 2019



On 28-04-2019 07:19 AM, mypopy at gmail.com wrote:
> On Sat, Apr 27, 2019 at 8:22 PM Gyan <ffmpeg at gyani.pro> wrote:
>>
>>
>> On 27-04-2019 05:25 PM, Carl Eugen Hoyos wrote:
>>> 2019-04-27 13:17 GMT+02:00, Jun Zhao <mypopydev at gmail.com>:
>>>> perfer avctx->framerate first than use avctx->time_base when
>>>> setting the frame rate to encoder. 1/time_base is not the
>>>> average frame rate if the frame rate is not constant.
>>> But why would the average framerate be a good choice to set
>>> the encoder timebase?
>>>
>> Also, note that x264/5 RC looks at the framerate.
>> See
>> https://code.videolan.org/videolan/x264/commit/c583687fab832ba7eaf8626048f05ad1f861a855
>>
>> I can generate a difference with x264 by setting -enc_time_base to
>> different values (with vsync vfr).
>> Maybe check that this change does not lead to a significant change in
>> output. Although I think this would be still an improvement for those
>> cases where r_frame_rate >> avg_frame_rate
>>
>> Gyan
> Yes, framerate and time_base is not close correlation in vfr case,
> e,g, I can setting the framerate = 60fps, but time_base = 1/1000 s,
> then setting pts like:
>
> time_base = 1/1000 s = 1 millisecond
> framerate = 60 fps per second
> PTS       0----16----33----50----66----83----100 ...
>
> PTS delta  16    17    17    16    17    17 ...
>
> we will get 16ms * 20 frames + 17 ms * 40 frames = 1000ms

I'm aware of the relationship between TB and PTS. My point is x264's RC 
adjusts its quantizer based on fps. You're changing that value so the 
output bitrate will change for the same input with the same encoder 
config if (avg_frame_rate) != (ticks * 1/TB).

Gyan


More information about the ffmpeg-devel mailing list