mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 21:56:31 +00:00
motion: h264 encoder respects quality settings
This commit is contained in:
parent
3e76cb2c34
commit
c1ed4cf807
33
package/motion/tune-h264-encode-quality.patch
Normal file
33
package/motion/tune-h264-encode-quality.patch
Normal file
@ -0,0 +1,33 @@
|
||||
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||
index 8f66121..9634a20 100644
|
||||
--- a/ffmpeg.c
|
||||
+++ b/ffmpeg.c
|
||||
@@ -451,20 +451,27 @@ static int ffmpeg_set_pts(struct ffmpeg *ffmpeg, const struct timeval *tv1){
|
||||
static int ffmpeg_set_quality(struct ffmpeg *ffmpeg){
|
||||
|
||||
char crf[4];
|
||||
+ int bit_rate;
|
||||
|
||||
ffmpeg->opts = 0;
|
||||
if (ffmpeg->vbr > 100) ffmpeg->vbr = 100;
|
||||
if (ffmpeg->ctx_codec->codec_id == MY_CODEC_ID_H264 ||
|
||||
ffmpeg->ctx_codec->codec_id == MY_CODEC_ID_HEVC){
|
||||
if (ffmpeg->vbr > 0) {
|
||||
+ if (ffmpeg->vbr < 10) ffmpeg->vbr = 10;
|
||||
+ //bit_rate = ffmpeg->width * ffmpeg->height * ffmpeg->fps * quality_factor
|
||||
+ bit_rate = (ffmpeg->width * ffmpeg->height * ffmpeg->fps * ffmpeg->vbr) >> 8;
|
||||
ffmpeg->vbr = (int)(( (100-ffmpeg->vbr) * 51)/100);
|
||||
} else {
|
||||
+ bit_rate = ffmpeg->bps;
|
||||
ffmpeg->vbr = 28;
|
||||
}
|
||||
snprintf(crf, 4, "%d",ffmpeg->vbr);
|
||||
- av_dict_set(&ffmpeg->opts, "preset", "ultrafast", 0);
|
||||
+ av_dict_set(&ffmpeg->opts, "preset", "slow", 0);
|
||||
av_dict_set(&ffmpeg->opts, "tune", "zerolatency", 0);
|
||||
av_dict_set(&ffmpeg->opts, "crf", crf, 0);
|
||||
+ ffmpeg->ctx_codec->profile = FF_PROFILE_H264_HIGH;
|
||||
+ ffmpeg->ctx_codec->bit_rate = bit_rate;
|
||||
} else {
|
||||
/* The selection of 8000 in the else is a subjective number based upon viewing output files */
|
||||
if (ffmpeg->vbr > 0){
|
Loading…
x
Reference in New Issue
Block a user