From d62aef2e50434cc31eccf236ae67d864becb7068 Mon Sep 17 00:00:00 2001 From: Sergei Iashin Date: Wed, 17 Feb 2021 22:12:13 +0300 Subject: [PATCH] libavformat/dashenc.c: check if packets were muxed before calculating average bitrate Prevents SIGFPE. Fixes issue #24738. Signed-off-by: James Almer --- libavformat/dashenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index c7aea0ce1c..6b4ab8eeb9 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -706,7 +706,9 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind if (os->bit_rate > 0) snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", os->bit_rate); else if (final) { - int average_bit_rate = os->pos * 8 * AV_TIME_BASE / c->total_duration; + int average_bit_rate = 0; + if (c->total_duration > 0) + average_bit_rate = os->pos * 8 * AV_TIME_BASE / c->total_duration; snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", average_bit_rate); } else if (os->first_segment_bit_rate > 0) snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"", os->first_segment_bit_rate);