From 7088217b0f08d5d2434a36579ce0ad6288df2e92 Mon Sep 17 00:00:00 2001 From: HawtDogFlvrWtr Date: Fri, 17 Apr 2020 06:25:40 -0400 Subject: [PATCH 1/4] Added support for nvenc hardware encoding as well as qsv. Disabled qsv for now, as driver install and ffmpeg functions are an issue to compile and test. nvenc works fine though and decreases CPU usage exponentially --- motioneye/handlers.py | 4 ++++ motioneye/motionctl.py | 35 +++++++++++++++++++++++++++++++++++ motioneye/templates/main.html | 6 ++++++ 3 files changed, 45 insertions(+) diff --git a/motioneye/handlers.py b/motioneye/handlers.py index da9e3afa0..4f53f317d 100644 --- a/motioneye/handlers.py +++ b/motioneye/handlers.py @@ -248,6 +248,10 @@ def get(self): admin_username=config.get_main().get('@admin_username'), has_h264_omx_support=motionctl.has_h264_omx_support(), has_h264_v4l2m2m_support=motionctl.has_h264_v4l2m2m_support(), + has_h264_nvenc_support=motionctl.has_h264_nvenc_support(), + has_hevc_nvenc_support=motionctl.has_hevc_nvenc_support(), + has_h264_qsv_support=motionctl.has_h264_qsv_support(), + has_hevc_qsv_support=motionctl.has_hevc_qsv_support(), has_motion=bool(motionctl.find_motion()[0]), mask_width=utils.MASK_WIDTH) diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index ee34ede1e..763d648d7 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -377,6 +377,41 @@ def has_h264_v4l2m2m_support(): return 'h264_v4l2m2m' in codecs.get('h264', {}).get('encoders', set()) +def has_h264_nvenc_support(): + binary, version, codecs = mediafiles.find_ffmpeg() + if not binary: + return False + + # TODO also check for motion codec parameter support + + return 'h264_nvenc' in codecs.get('h264', {}).get('encoders', set()) + +def has_hevc_nvenc_support(): + binary, version, codecs = mediafiles.find_ffmpeg() + if not binary: + return False + + # TODO also check for motion codec parameter support + + return 'hevc_nvenc' in codecs.get('hevc', {}).get('encoders', set()) + +def has_h264_qsv_support(): + binary, version, codecs = mediafiles.find_ffmpeg() + if not binary: + return False + + # TODO also check for motion codec parameter support + + return 'h264_qsv' in codecs.get('h264', {}).get('encoders', set()) + +def has_hevc_qsv_support(): + binary, version, codecs = mediafiles.find_ffmpeg() + if not binary: + return False + + # TODO also check for motion codec parameter support + + return 'hevc_qsv' in codecs.get('hevc', {}).get('encoders', set()) def resolution_is_valid(width, height): # width & height must be be modulo 8 diff --git a/motioneye/templates/main.html b/motioneye/templates/main.html index 9b71f3223..3ccaf7694 100644 --- a/motioneye/templates/main.html +++ b/motioneye/templates/main.html @@ -763,6 +763,9 @@ + {% if has_h264_nvenc_support %} + + {% endif %} {% if has_h264_omx_support %} {% endif %} @@ -770,6 +773,9 @@ {% endif %} + {% if has_hevc_nvenc_support %} + + {% endif %} {% if has_h264_omx_support %} From 3d23a83f705c801c194b31ba640290108458f643 Mon Sep 17 00:00:00 2001 From: HawtDogFlvrWtr Date: Fri, 24 Apr 2020 09:43:21 -0400 Subject: [PATCH 2/4] added final support for hardware encoding qsv, and nvmpi --- motioneye/handlers.py | 2 ++ motioneye/motionctl.py | 18 ++++++++++++++++++ motioneye/templates/main.html | 14 +++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/motioneye/handlers.py b/motioneye/handlers.py index 4f53f317d..48a6fc915 100644 --- a/motioneye/handlers.py +++ b/motioneye/handlers.py @@ -249,7 +249,9 @@ def get(self): has_h264_omx_support=motionctl.has_h264_omx_support(), has_h264_v4l2m2m_support=motionctl.has_h264_v4l2m2m_support(), has_h264_nvenc_support=motionctl.has_h264_nvenc_support(), + has_h264_nvmpi_support=motionctl.has_h264_nvmpi_support(), has_hevc_nvenc_support=motionctl.has_hevc_nvenc_support(), + has_hevc_nvmpi_support=motionctl.has_hevc_nvmpi_support(), has_h264_qsv_support=motionctl.has_h264_qsv_support(), has_hevc_qsv_support=motionctl.has_hevc_qsv_support(), has_motion=bool(motionctl.find_motion()[0]), diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index 763d648d7..0801a65a8 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -386,6 +386,24 @@ def has_h264_nvenc_support(): return 'h264_nvenc' in codecs.get('h264', {}).get('encoders', set()) +def has_h264_nvmpi_support(): + binary, version, codecs = mediafiles.find_ffmpeg() + if not binary: + return False + + # TODO also check for motion codec parameter support + + return 'h264_nvmpi' in codecs.get('h264', {}).get('encoders', set()) + +def has_hevc_nvmpi_support(): + binary, version, codecs = mediafiles.find_ffmpeg() + if not binary: + return False + + # TODO also check for motion codec parameter support + + return 'hevc_nvmpi' in codecs.get('hevc', {}).get('encoders', set()) + def has_hevc_nvenc_support(): binary, version, codecs = mediafiles.find_ffmpeg() if not binary: diff --git a/motioneye/templates/main.html b/motioneye/templates/main.html index 3ccaf7694..07fd17606 100644 --- a/motioneye/templates/main.html +++ b/motioneye/templates/main.html @@ -766,6 +766,12 @@ {% if has_h264_nvenc_support %} {% endif %} + {% if has_h264_nvmpi_support %} + + {% endif %} + {% if has_h264_qsv_support %} + + {% endif %} {% if has_h264_omx_support %} {% endif %} @@ -774,7 +780,13 @@ {% endif %} {% if has_hevc_nvenc_support %} - + + {% endif %} + {% if has_hevc_nvmpi_support %} + + {% endif %} + {% if has_hevc_qsv_support %} + {% endif %} {% if has_h264_omx_support %} From 99cd37dd5cb79e67132fe8da61f93f0aadb44e2c Mon Sep 17 00:00:00 2001 From: mmeah Date: Fri, 8 May 2020 18:21:15 -0500 Subject: [PATCH 3/4] Insert py file to sys path first to avoid confusing second instance folder with one installed in python directory --- motioneye/meyectl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motioneye/meyectl.py b/motioneye/meyectl.py index 64a445a1f..a2ad61294 100755 --- a/motioneye/meyectl.py +++ b/motioneye/meyectl.py @@ -23,7 +23,7 @@ import sys # make sure motioneye is on python path -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import settings From 9c2da1c41ed7a74fdbf773e82ab421c9b96a80ba Mon Sep 17 00:00:00 2001 From: Sean Danischevsky <32126021+seaniedan@users.noreply.github.com> Date: Wed, 13 May 2020 14:28:45 +0100 Subject: [PATCH 4/4] Update main.js filenameValidRegExp should allow Conversion Specifier %C so that images and movies can reference the value defined by 'text_event'. --- motioneye/static/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js index 7f655da00..5da730bf1 100644 --- a/motioneye/static/js/main.js +++ b/motioneye/static/js/main.js @@ -18,7 +18,7 @@ var passwordHash = ''; var basePath = null; var signatureRegExp = new RegExp('[^A-Za-z0-9/?_.=&{}\\[\\]":, -]', 'g'); var deviceNameValidRegExp = new RegExp('^[A-Za-z0-9\-\_\+\ ]+$'); -var filenameValidRegExp = new RegExp('^([A-Za-z0-9 \(\)/._-]|%[YmdHMSqv])+$'); +var filenameValidRegExp = new RegExp('^([A-Za-z0-9 \(\)/._-]|%[CYmdHMSqv])+$'); var dirnameValidRegExp = new RegExp('^[A-Za-z0-9 \(\)/._-]+$'); var emailValidRegExp = new RegExp('^[A-Za-z0-9 _+.@^~<>,-]+$'); var initialConfigFetched = false; /* used to workaround browser extensions that trigger stupid change events */