From e8161e28253f82bbbd4e0c19ef058251e4f3ea18 Mon Sep 17 00:00:00 2001 From: jasaw Date: Mon, 12 Aug 2019 12:39:44 +1000 Subject: [PATCH] ffmpeg: do bitrate calculation in 64 bits to prevent overflow (#959) --- ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index a8afa6e6..3f731cac 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -558,7 +558,7 @@ static int ffmpeg_set_quality(struct ffmpeg *ffmpeg){ if ((strcmp(ffmpeg->codec->name, "h264_omx") == 0) || (strcmp(ffmpeg->codec->name, "mpeg4_omx") == 0)) { // H264 OMX encoder quality can only be controlled via bit_rate // bit_rate = ffmpeg->width * ffmpeg->height * ffmpeg->fps * quality_factor - ffmpeg->quality = (ffmpeg->width * ffmpeg->height * ffmpeg->fps * ffmpeg->quality) >> 7; + ffmpeg->quality = (int)(((int64_t)ffmpeg->width * ffmpeg->height * ffmpeg->fps * ffmpeg->quality) >> 7); // Clip bit rate to min if (ffmpeg->quality < 4000) // magic number ffmpeg->quality = 4000;