[FFmpeg-devel] [PATCH 4/5] avformat/movenc: use more fall-back values for average bit rate fields
Martin Storsjö
martin at martin.st
Mon Sep 21 13:13:54 EEST 2020
On Sun, 20 Sep 2020, Jan Ekström wrote:
> If the average bit rate cannot be calculated, such as in the case
> of streamed fragmented mp4, utilize various available parameters
> in priority order.
>
> Tests are updated where the esds or btrt or ISML manifest boxes'
> output changes.
> ---
> libavformat/movenc.c | 17 +++++++++++++++++
> tests/ref/lavf/ismv | 6 +++---
> 2 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 9bff2c89ca..0f14e255e9 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -647,6 +647,23 @@ static struct mpeg4_bit_rate_values calculate_mpeg4_bit_rates(MOVTrack *track)
> NULL);
> unsigned avg_bit_rate = compute_avg_bitrate(track);
>
> + if (!avg_bit_rate) {
> + // if there is no calculate'able average bit rate, such as
Nit: calculatable?
> + // in the case of fragmented MP4, utilize the following values
> + // in priority order:
> + //
> + // 1. average bit rate property
> + // 2. bit rate (usually average over the whole clip)
> + // 3. maximum bit rate property
> +
> + if (props && props->avg_bitrate) {
> + avg_bit_rate = props->avg_bitrate;
> + } else if (track->par->bit_rate) {
> + avg_bit_rate = track->par->bit_rate;
> + } else if (props && props->max_bitrate) {
> + avg_bit_rate = props->max_bitrate;
> + }
> + }
Code looks sensible though, I guess.
// Martin
More information about the ffmpeg-devel
mailing list