[FFmpeg-devel] [PATCH v3 3/3] avcodec: estimate output bitrate for ffv1/huffyuv codecs
Tobias Rapp
t.rapp at noa-archive.com
Tue Mar 14 14:52:40 EET 2017
On 11.03.2017 16:29, Michael Niedermayer wrote:
> On Tue, Mar 07, 2017 at 03:39:19PM +0100, Tobias Rapp wrote:
>> Allows to get a more realistic total bitrate (and estimated file size)
>> in avi_write_header. Previously a static default value of 200k was
>> assumed.
>>
>> Signed-off-by: Tobias Rapp <t.rapp at noa-archive.com>
>> ---
>> libavcodec/ffv1enc.c | 3 +++
>> libavcodec/huffyuvenc.c | 3 +++
>> tests/ref/vsynth/vsynth1-ffv1 | 2 +-
>> tests/ref/vsynth/vsynth1-ffv1-v0 | 2 +-
>> tests/ref/vsynth/vsynth1-ffv1-v3-bgr0 | 2 +-
>> tests/ref/vsynth/vsynth1-ffv1-v3-rgb48 | 2 +-
>> tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p | 2 +-
>> tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10 | 2 +-
>> tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16 | 2 +-
>> tests/ref/vsynth/vsynth1-ffvhuff | 2 +-
>> tests/ref/vsynth/vsynth1-ffvhuff420p12 | 2 +-
>> tests/ref/vsynth/vsynth1-ffvhuff422p10left | 2 +-
>> tests/ref/vsynth/vsynth1-ffvhuff444 | 2 +-
>> tests/ref/vsynth/vsynth1-ffvhuff444p16 | 2 +-
>> tests/ref/vsynth/vsynth1-huffyuv | 2 +-
>> tests/ref/vsynth/vsynth1-huffyuvbgr24 | 2 +-
>> tests/ref/vsynth/vsynth1-huffyuvbgra | 2 +-
>> tests/ref/vsynth/vsynth2-ffv1 | 2 +-
>> tests/ref/vsynth/vsynth2-ffv1-v0 | 2 +-
>> tests/ref/vsynth/vsynth2-ffv1-v3-bgr0 | 2 +-
>> tests/ref/vsynth/vsynth2-ffv1-v3-rgb48 | 2 +-
>> tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p | 2 +-
>> tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10 | 2 +-
>> tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16 | 2 +-
>> tests/ref/vsynth/vsynth2-ffvhuff | 2 +-
>> tests/ref/vsynth/vsynth2-ffvhuff420p12 | 2 +-
>> tests/ref/vsynth/vsynth2-ffvhuff422p10left | 2 +-
>> tests/ref/vsynth/vsynth2-ffvhuff444 | 2 +-
>> tests/ref/vsynth/vsynth2-ffvhuff444p16 | 2 +-
>> tests/ref/vsynth/vsynth2-huffyuv | 2 +-
>> tests/ref/vsynth/vsynth2-huffyuvbgr24 | 2 +-
>> tests/ref/vsynth/vsynth2-huffyuvbgra | 2 +-
>> tests/ref/vsynth/vsynth3-ffv1 | 2 +-
>> tests/ref/vsynth/vsynth3-ffv1-v0 | 2 +-
>> tests/ref/vsynth/vsynth3-ffv1-v3-bgr0 | 2 +-
>> tests/ref/vsynth/vsynth3-ffv1-v3-rgb48 | 2 +-
>> tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p | 2 +-
>> tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10 | 2 +-
>> tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16 | 2 +-
>> tests/ref/vsynth/vsynth3-ffvhuff | 2 +-
>> tests/ref/vsynth/vsynth3-ffvhuff420p12 | 2 +-
>> tests/ref/vsynth/vsynth3-ffvhuff422p10left | 2 +-
>> tests/ref/vsynth/vsynth3-ffvhuff444 | 2 +-
>> tests/ref/vsynth/vsynth3-ffvhuff444p16 | 2 +-
>> tests/ref/vsynth/vsynth3-huffyuv | 2 +-
>> tests/ref/vsynth/vsynth3-huffyuvbgr24 | 2 +-
>> tests/ref/vsynth/vsynth3-huffyuvbgra | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffv1 | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffv1-v0 | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffv1-v3-bgr0 | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffv1-v3-rgb48 | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420p | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv422p10 | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv444p16 | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffvhuff | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffvhuff420p12 | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffvhuff422p10left | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffvhuff444 | 2 +-
>> tests/ref/vsynth/vsynth_lena-ffvhuff444p16 | 2 +-
>> tests/ref/vsynth/vsynth_lena-huffyuv | 2 +-
>> tests/ref/vsynth/vsynth_lena-huffyuvbgr24 | 2 +-
>> tests/ref/vsynth/vsynth_lena-huffyuvbgra | 2 +-
>> 62 files changed, 66 insertions(+), 60 deletions(-)
>>
>> diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
>> index 35f54c6..b57e8ba 100644
>> --- a/libavcodec/ffv1enc.c
>> +++ b/libavcodec/ffv1enc.c
>> @@ -894,6 +894,9 @@ slices_ok:
>> }
>> }
>>
>> + // estimate compressed bitrate assuming 40% output size
>> + avctx->bit_rate = ff_guess_coded_bitrate(avctx) * 2 / 5;
>> +
>> return 0;
>> }
>>
>> diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
>> index 89639b7..ddbaf14 100644
>> --- a/libavcodec/huffyuvenc.c
>> +++ b/libavcodec/huffyuvenc.c
>> @@ -446,6 +446,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>
>> s->picture_number=0;
>>
>> + // estimate compressed bitrate assuming 60% output size
>> + avctx->bit_rate = ff_guess_coded_bitrate(avctx) * 3 / 5;
>
> i dont like this, the value is basically random, and not the bitrate
OK, then consider this patch as dropped.
IMHO the current static value of 200000 is even worse but I can do the
estimation outside of avcodec and pass it to the encoder/muxer via the
"b" option.
Regards,
Tobias
More information about the ffmpeg-devel
mailing list