diff options
author | Michael Niedermayer <[email protected]> | 2018-05-01 22:44:07 +0200 |
---|---|---|
committer | Michael Niedermayer <[email protected]> | 2018-07-16 19:06:27 +0200 |
commit | b5d51d23a068f7511662acd363b39d2f922dff0e (patch) | |
tree | 61c76bf8acb12c29dceeb7b8990a2bd1aec3c350 /ffmpeg.c | |
parent | 98f10ca12ccc1accafbf26d9eeb6e7c91bd650eb (diff) |
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 <[email protected]>
(cherry picked from commit 16d8b13b3b26c19d7f8856e039fe6662d96b4ff3)
Signed-off-by: Michael Niedermayer <[email protected]>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -2725,8 +2725,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) { |