avformat/movenc: Check frame rate before use.

Fixes division by 0
This is similar to how avg_frame_rate is checked elsewhere
Fixes: 6d24add0455f41b1b45b7ba615cd46f3/asan_generic_dc34c3_5480_0a2ef411cae999b9871ed71a2e481b71.mov

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
pull/241/head
Michael Niedermayer 8 years ago
parent ae514b1254
commit 709c87109d
  1. 4
      libavformat/movenc.c

@ -4291,7 +4291,9 @@ static int mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
AVCodecParameters *video_par = s->streams[0]->codecpar; AVCodecParameters *video_par = s->streams[0]->codecpar;
AVCodecParameters *audio_par = s->streams[1]->codecpar; AVCodecParameters *audio_par = s->streams[1]->codecpar;
int audio_rate = audio_par->sample_rate; int audio_rate = audio_par->sample_rate;
int64_t frame_rate = (video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den; int64_t frame_rate = video_st->avg_frame_rate.den ?
(video_st->avg_frame_rate.num * 0x10000LL) / video_st->avg_frame_rate.den :
0;
int audio_kbitrate = audio_par->bit_rate / 1000; int audio_kbitrate = audio_par->bit_rate / 1000;
int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate); int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate);

Loading…
Cancel
Save