mirror of
https://github.com/Motion-Project/motion.git
synced 2026-02-03 03:21:38 -05:00
ffmpeg: do bitrate calculation in 64 bits to prevent overflow (#959)
This commit is contained in:
2
ffmpeg.c
2
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;
|
||||
|
||||
Reference in New Issue
Block a user