aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-05-01 22:44:07 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-06-15 22:31:13 +0200
commit1ca157b0267e46d849e3b4001d6c0f87ed82ad53 (patch)
treec836dfd887955aec80c1c902f83c19f887251309 /fftools/ffmpeg.c
parentf36128518b5de543873df3eeeda460b8d54852fc (diff)
downloadffmpeg-1ca157b0267e46d849e3b4001d6c0f87ed82ad53.tar.gz
fftools/ffmpeg: Fallback to duration if sample rate is unavailable
Regression since: af1761f7 Fixes: Division by 0 Fixes: ffmpeg_crash_1 Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan Caciulescu with AFLSmart Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 16d8b13b3b26c19d7f8856e039fe6662d96b4ff3) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r--fftools/ffmpeg.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 4dbe72186d..16ce07c3ab 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2696,8 +2696,12 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
ist->dts = ist->next_dts;
switch (ist->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /
- ist->dec_ctx->sample_rate;
+ if (ist->dec_ctx->sample_rate) {
+ ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /
+ ist->dec_ctx->sample_rate;
+ } else {
+ ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
+ }
break;
case AVMEDIA_TYPE_VIDEO:
if (ist->framerate.num) {