mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 14:16:31 +00:00
motion: only tune h264_omx encode quality
This commit is contained in:
parent
6c980d667c
commit
6ba62abe64
@ -1,8 +1,8 @@
|
|||||||
diff --git a/ffmpeg.c b/ffmpeg.c
|
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||||
index a4d3757..124b41f 100644
|
index a4d3757..368c855 100644
|
||||||
--- a/ffmpeg.c
|
--- a/ffmpeg.c
|
||||||
+++ b/ffmpeg.c
|
+++ b/ffmpeg.c
|
||||||
@@ -451,21 +451,29 @@ static int ffmpeg_set_pts(struct ffmpeg *ffmpeg, const struct timeval *tv1){
|
@@ -451,7 +451,7 @@ static int ffmpeg_set_pts(struct ffmpeg *ffmpeg, const struct timeval *tv1){
|
||||||
|
|
||||||
static int ffmpeg_set_quality(struct ffmpeg *ffmpeg){
|
static int ffmpeg_set_quality(struct ffmpeg *ffmpeg){
|
||||||
|
|
||||||
@ -11,13 +11,12 @@ index a4d3757..124b41f 100644
|
|||||||
|
|
||||||
ffmpeg->opts = 0;
|
ffmpeg->opts = 0;
|
||||||
if (ffmpeg->vbr > 100) ffmpeg->vbr = 100;
|
if (ffmpeg->vbr > 100) ffmpeg->vbr = 100;
|
||||||
if (ffmpeg->ctx_codec->codec_id == MY_CODEC_ID_H264 ||
|
@@ -459,13 +459,24 @@ static int ffmpeg_set_quality(struct ffmpeg *ffmpeg){
|
||||||
ffmpeg->ctx_codec->codec_id == MY_CODEC_ID_HEVC){
|
ffmpeg->ctx_codec->codec_id == MY_CODEC_ID_HEVC){
|
||||||
if (ffmpeg->vbr > 0) {
|
if (ffmpeg->vbr > 0) {
|
||||||
+ if (ffmpeg->vbr < 10) ffmpeg->vbr = 10;
|
ffmpeg->vbr = (int)(( (100-ffmpeg->vbr) * 51)/100);
|
||||||
+ //bit_rate = ffmpeg->width * ffmpeg->height * ffmpeg->fps * quality_factor
|
+ //bit_rate = ffmpeg->width * ffmpeg->height * ffmpeg->fps * quality_factor
|
||||||
+ bit_rate = (ffmpeg->width * ffmpeg->height * ffmpeg->fps * ffmpeg->vbr) >> 8;
|
+ bit_rate = (ffmpeg->width * ffmpeg->height * ffmpeg->fps * ffmpeg->vbr) >> 8;
|
||||||
ffmpeg->vbr = (int)(( (100-ffmpeg->vbr) * 51)/100);
|
|
||||||
} else {
|
} else {
|
||||||
+ bit_rate = ffmpeg->bps;
|
+ bit_rate = ffmpeg->bps;
|
||||||
ffmpeg->vbr = 28;
|
ffmpeg->vbr = 28;
|
||||||
@ -26,14 +25,18 @@ index a4d3757..124b41f 100644
|
|||||||
- av_dict_set(&ffmpeg->opts, "preset", "ultrafast", 0);
|
- av_dict_set(&ffmpeg->opts, "preset", "ultrafast", 0);
|
||||||
- av_dict_set(&ffmpeg->opts, "tune", "zerolatency", 0);
|
- av_dict_set(&ffmpeg->opts, "tune", "zerolatency", 0);
|
||||||
- av_dict_set(&ffmpeg->opts, "crf", crf, 0);
|
- av_dict_set(&ffmpeg->opts, "crf", crf, 0);
|
||||||
+ // Clip to max bit rate
|
|
||||||
+ if (bit_rate > 2500000)
|
|
||||||
+ bit_rate = 2500000;
|
|
||||||
+ av_dict_set(&ffmpeg->opts, "preset", "ultrafast", 0);
|
+ av_dict_set(&ffmpeg->opts, "preset", "ultrafast", 0);
|
||||||
+ av_dict_set(&ffmpeg->opts, "tune", "zerolatency", 0);
|
+ av_dict_set(&ffmpeg->opts, "tune", "zerolatency", 0);
|
||||||
+ av_dict_set_int(&ffmpeg->opts, "crf", ffmpeg->vbr, 0);
|
+ av_dict_set_int(&ffmpeg->opts, "crf", ffmpeg->vbr, 0);
|
||||||
+ ffmpeg->ctx_codec->profile = FF_PROFILE_H264_HIGH;
|
+ if ((strcmp(ffmpeg->codec->name, "h264_omx") == 0) || (strcmp(ffmpeg->codec->name, "mpeg4_omx") == 0)) {
|
||||||
+ ffmpeg->ctx_codec->bit_rate = bit_rate;
|
+ // Clip bit rate to min and max
|
||||||
|
+ if (bit_rate < 40000)
|
||||||
|
+ bit_rate = 40000;
|
||||||
|
+ else if (bit_rate > 3000000)
|
||||||
|
+ bit_rate = 3000000;
|
||||||
|
+ ffmpeg->ctx_codec->profile = FF_PROFILE_H264_HIGH;
|
||||||
|
+ ffmpeg->ctx_codec->bit_rate = bit_rate;
|
||||||
|
+ }
|
||||||
} else {
|
} else {
|
||||||
/* The selection of 8000 in the else is a subjective number based upon viewing output files */
|
/* The selection of 8000 in the else is a subjective number based upon viewing output files */
|
||||||
if (ffmpeg->vbr > 0){
|
if (ffmpeg->vbr > 0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user