mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 13:46:32 +00:00
disable ffmpeg zerocopy, motion not use extpipe
This commit is contained in:
parent
10ede33068
commit
6c980d667c
15
package/ffmpeg/disable-rpi-omx-input-zerocopy.patch
Normal file
15
package/ffmpeg/disable-rpi-omx-input-zerocopy.patch
Normal file
@ -0,0 +1,15 @@
|
||||
diff --git a/libavcodec/omx.c b/libavcodec/omx.c
|
||||
index 19b4f33836..4641dc79e2 100644
|
||||
--- a/libavcodec/omx.c
|
||||
+++ b/libavcodec/omx.c
|
||||
@@ -644,10 +644,6 @@ static av_cold int omx_encode_init(AVCodecContext *avctx)
|
||||
OMX_BUFFERHEADERTYPE *buffer;
|
||||
OMX_ERRORTYPE err;
|
||||
|
||||
-#if CONFIG_OMX_RPI
|
||||
- s->input_zerocopy = 1;
|
||||
-#endif
|
||||
-
|
||||
s->omx_context = omx_init(avctx, s->libname, s->libprefix);
|
||||
if (!s->omx_context)
|
||||
return AVERROR_ENCODER_NOT_FOUND;
|
19
package/motion/prefer-omx-encoder.patch
Normal file
19
package/motion/prefer-omx-encoder.patch
Normal file
@ -0,0 +1,19 @@
|
||||
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||
index 71685a1..07ce41c 100644
|
||||
--- a/ffmpeg.c
|
||||
+++ b/ffmpeg.c
|
||||
@@ -485,7 +485,13 @@ static int ffmpeg_set_codec(struct ffmpeg *ffmpeg){
|
||||
char errstr[128];
|
||||
int chkrate;
|
||||
|
||||
- ffmpeg->codec = avcodec_find_encoder(ffmpeg->oc->oformat->video_codec);
|
||||
+ ffmpeg->codec = NULL;
|
||||
+ if (ffmpeg->oc->oformat->video_codec == AV_CODEC_ID_H264)
|
||||
+ ffmpeg->codec = avcodec_find_encoder_by_name("h264_omx");
|
||||
+ else if (ffmpeg->oc->oformat->video_codec == AV_CODEC_ID_MPEG4)
|
||||
+ ffmpeg->codec = avcodec_find_encoder_by_name("mpeg4_omx");
|
||||
+ if (!ffmpeg->codec)
|
||||
+ ffmpeg->codec = avcodec_find_encoder(ffmpeg->oc->oformat->video_codec);
|
||||
if (!ffmpeg->codec) {
|
||||
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "Codec %s not found", ffmpeg->codec_name);
|
||||
ffmpeg_free_context(ffmpeg);
|
39
package/motion/tune-h264-encode-quality.patch
Normal file
39
package/motion/tune-h264-encode-quality.patch
Normal file
@ -0,0 +1,39 @@
|
||||
diff --git a/ffmpeg.c b/ffmpeg.c
|
||||
index a4d3757..124b41f 100644
|
||||
--- a/ffmpeg.c
|
||||
+++ b/ffmpeg.c
|
||||
@@ -451,21 +451,29 @@ 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, "tune", "zerolatency", 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, "tune", "zerolatency", 0);
|
||||
+ av_dict_set_int(&ffmpeg->opts, "crf", ffmpeg->vbr, 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){
|
@ -1,94 +0,0 @@
|
||||
commit d6b2e8203453c75e3b64a441a66091d9a099f31e
|
||||
Author: Joo Aun Saw <jasaw@dius.com.au>
|
||||
Date: Mon Aug 7 12:09:04 2017 +1000
|
||||
|
||||
Use extpipe ffmpeg h264_omx encoder
|
||||
|
||||
Use ffmpeg h264_omx hardware accelerated encoder via extpipe when output
|
||||
video format is H264. Applies to mp4 and mkv containers.
|
||||
|
||||
diff --git a/motioneye/config.py b/motioneye/config.py
|
||||
index 48e8cf5..ddf10c9 100644
|
||||
--- a/motioneye/config.py
|
||||
+++ b/motioneye/config.py
|
||||
@@ -58,6 +58,10 @@ _EXPONENTIAL_QUALITY_FACTOR = 100000 # voodoo
|
||||
_EXPONENTIAL_DEF_QUALITY = 511 # about 75%
|
||||
_MAX_FFMPEG_VARIABLE_BITRATE = 32767
|
||||
|
||||
+_EXTPIPE_FFMPEG_H264_OMX_CODEC = {'mp4', 'mkv'}
|
||||
+_EXTPIPE_FFMPEG_H264_OMX_CODEC_ARGS = {'mp4':'-f mp4 %f.mp4', 'mkv':'-f matroska %f.mkv'}
|
||||
+_EXTPIPE_FFMPEG_H264_OMX_CMD = 'ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %fps -i pipe:0 -c:v h264_omx -profile:v high -b:v 3000000'
|
||||
+
|
||||
_KNOWN_MOTION_OPTIONS = set([
|
||||
'auto_brightness',
|
||||
'brightness',
|
||||
@@ -118,6 +122,8 @@ _KNOWN_MOTION_OPTIONS = set([
|
||||
'threshold',
|
||||
'videodevice',
|
||||
'width',
|
||||
+ 'use_extpipe',
|
||||
+ 'extpipe',
|
||||
])
|
||||
|
||||
|
||||
@@ -737,6 +743,8 @@ def motion_camera_ui_to_dict(ui, old_config=None):
|
||||
'movie_filename': ui['movie_file_name'],
|
||||
'max_movie_time': ui['max_movie_length'],
|
||||
'@preserve_movies': int(ui['preserve_movies']),
|
||||
+ 'use_extpipe': False,
|
||||
+ 'extpipe': '',
|
||||
|
||||
# motion detection
|
||||
'@motion_detection': ui['motion_detection'],
|
||||
@@ -919,6 +927,11 @@ def motion_camera_ui_to_dict(ui, old_config=None):
|
||||
elif recording_mode == 'continuous':
|
||||
data['emulate_motion'] = True
|
||||
|
||||
+ if ui['movie_format'] in _EXTPIPE_FFMPEG_H264_OMX_CODEC:
|
||||
+ data['ffmpeg_output_movies'] = False
|
||||
+ data['use_extpipe'] = True
|
||||
+ data['extpipe'] = _EXTPIPE_FFMPEG_H264_OMX_CMD + ' ' + _EXTPIPE_FFMPEG_H264_OMX_CODEC_ARGS[ui['movie_format']]
|
||||
+
|
||||
data['ffmpeg_video_codec'] = ui['movie_format']
|
||||
q = int(ui['movie_quality'])
|
||||
if motionctl.needs_ffvb_quirks():
|
||||
@@ -1120,6 +1133,8 @@ def motion_camera_dict_to_ui(data):
|
||||
'movie_file_name': data['movie_filename'],
|
||||
'max_movie_length': data['max_movie_time'],
|
||||
'preserve_movies': data['@preserve_movies'],
|
||||
+ 'use_extpipe': False,
|
||||
+ 'extpipe': '',
|
||||
|
||||
# motion detection
|
||||
'motion_detection': data['@motion_detection'],
|
||||
@@ -1303,7 +1318,7 @@ def motion_camera_dict_to_ui(data):
|
||||
if picture_filename:
|
||||
ui['image_file_name'] = picture_filename
|
||||
|
||||
- if data['ffmpeg_output_movies']:
|
||||
+ if data['ffmpeg_output_movies'] or data['use_extpipe']:
|
||||
ui['movies'] = True
|
||||
|
||||
if emulate_motion:
|
||||
@@ -1883,6 +1898,8 @@ def _set_default_motion_camera(camera_id, data):
|
||||
|
||||
data.setdefault('movie_filename', '%Y-%m-%d/%H-%M-%S')
|
||||
data.setdefault('max_movie_time', 0)
|
||||
+ data.setdefault('use_extpipe', False)
|
||||
+ data.setdefault('extpipe', '')
|
||||
data.setdefault('ffmpeg_output_movies', False)
|
||||
if motionctl.has_new_movie_format_support():
|
||||
data.setdefault('ffmpeg_video_codec', 'mp4') # will use h264 codec
|
||||
diff --git a/motioneye/mediafiles.py b/motioneye/mediafiles.py
|
||||
index 680cdd9..cc54008 100644
|
||||
--- a/motioneye/mediafiles.py
|
||||
+++ b/motioneye/mediafiles.py
|
||||
@@ -216,7 +216,7 @@ def cleanup_media(media_type):
|
||||
((camera_config['emulate_motion'] or camera_config['output_pictures']) and camera_config['picture_filename']) or
|
||||
(camera_config['snapshot_interval'] and camera_config['snapshot_filename']))
|
||||
|
||||
- movies_enabled = camera_config['ffmpeg_output_movies']
|
||||
+ movies_enabled = camera_config['ffmpeg_output_movies'] or camera_config['use_extpipe']
|
||||
|
||||
if media_type == 'picture' and not still_images_enabled:
|
||||
continue # only cleanup pictures for cameras with still images enabled
|
Loading…
x
Reference in New Issue
Block a user