From e0514485099a7adc8e37dfc7047bb387bf261fab Mon Sep 17 00:00:00 2001 From: Joo Aun Saw Date: Fri, 4 Aug 2017 14:52:53 +1000 Subject: [PATCH] don't use h264_omx via C API, use extpipe instead motion interfacing with ffmpeg C API proved to be unstable. --- package/motion/prefer-omx-encoders.patch | 24 -------------- package/motion/tune-h264-encode-quality.patch | 33 ------------------- .../allow-extpipe-motion-option.patch | 19 +++++++++++ 3 files changed, 19 insertions(+), 57 deletions(-) delete mode 100644 package/motion/prefer-omx-encoders.patch delete mode 100644 package/motion/tune-h264-encode-quality.patch create mode 100644 package/motioneye/allow-extpipe-motion-option.patch diff --git a/package/motion/prefer-omx-encoders.patch b/package/motion/prefer-omx-encoders.patch deleted file mode 100644 index b3f778e950..0000000000 --- a/package/motion/prefer-omx-encoders.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/ffmpeg.c b/ffmpeg.c -index 30a9cde..829d5a2 100644 ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -484,7 +484,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, "%s: Codec %s not found", ffmpeg->codec_name); - ffmpeg_free_context(ffmpeg); -@@ -926,4 +932,3 @@ int ffmpeg_put_image(struct ffmpeg *ffmpeg, unsigned char *image, const struct t - return 0; - #endif // HAVE_FFMPEG - } -- diff --git a/package/motion/tune-h264-encode-quality.patch b/package/motion/tune-h264-encode-quality.patch deleted file mode 100644 index 29d561b3d9..0000000000 --- a/package/motion/tune-h264-encode-quality.patch +++ /dev/null @@ -1,33 +0,0 @@ -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){ diff --git a/package/motioneye/allow-extpipe-motion-option.patch b/package/motioneye/allow-extpipe-motion-option.patch new file mode 100644 index 0000000000..f77bff853a --- /dev/null +++ b/package/motioneye/allow-extpipe-motion-option.patch @@ -0,0 +1,19 @@ +commit 7a916dea0c90f7040ce3c5a78da560edc4d9ba53 +Author: Joo Aun Saw +Date: Fri Aug 4 14:36:04 2017 +1000 + + allow extpipe motion option + +diff --git a/motioneye/config.py b/motioneye/config.py +index 48e8cf5..1b1b087 100644 +--- a/motioneye/config.py ++++ b/motioneye/config.py +@@ -118,6 +118,8 @@ _KNOWN_MOTION_OPTIONS = set([ + 'threshold', + 'videodevice', + 'width', ++ 'use_extpipe', ++ 'extpipe', + ]) + +