diff options
author | Jun Zhao <barryjzhao@tencent.com> | 2020-05-17 12:10:05 +0800 |
---|---|---|
committer | Jun Zhao <barryjzhao@tencent.com> | 2020-06-26 09:53:36 +0800 |
commit | 60d79b1df9d4c6030010ccb0c134ede9e33158c2 (patch) | |
tree | eca70df320e7b35240d68f1eed3a8f148a730203 /libavcodec/aac_ac3_parser.c | |
parent | a8fb7612a97530bdd0b2549dacf91dcf71a3187a (diff) | |
download | ffmpeg-60d79b1df9d4c6030010ccb0c134ede9e33158c2.tar.gz |
lavc/aac_ac3_parser: improve the raw AAC file bit rate calculation
Now we just use one ADTS raw frame to calculate the bit rate, it's
lead to a larger error when get the duration from bit rate, the
improvement cumulate Nth ADTS frames to get the average bit rate.
e,g used the command get the duration like:
ffprobe -show_entries format=duration -i fate-suite/aac/foo.aac
before this improvement dump the duration=2.173935
after this improvement dump the duration=1.979267
in fact, the real duration can be get by command like:
ffmpeg -i fate-suite/aac/foo.aac -f null /dev/null with time=00:00:01.97
Also update the fate-adtstoasc_ticket3715.
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Diffstat (limited to 'libavcodec/aac_ac3_parser.c')
-rw-r--r-- | libavcodec/aac_ac3_parser.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c index 54e459844f..0746798dab 100644 --- a/libavcodec/aac_ac3_parser.c +++ b/libavcodec/aac_ac3_parser.c @@ -97,8 +97,13 @@ get_next: avctx->audio_service_type = s->service_type; } - if (avctx->codec_id != AV_CODEC_ID_EAC3) - avctx->bit_rate = s->bit_rate; + /* Calculate the average bit rate */ + s->frame_number++; + if (avctx->codec_id != AV_CODEC_ID_EAC3) { + avctx->bit_rate = + (s->last_bit_rate * (s->frame_number -1) + s->bit_rate)/s->frame_number; + s->last_bit_rate = avctx->bit_rate; + } } return i; |