From 96b4af6255b0f1d9e5306c74bca4e808987d4659 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 17 Nov 2021 14:43:13 -0500 Subject: [PATCH 1/2] Enable multi-threading on decode --- src/zm_ffmpeg_camera.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index b122e0f2b..728b51783 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -458,6 +458,17 @@ int FfmpegCamera::OpenFfmpeg() { #endif } // end if hwaccel_name + // set codec to automatically determine how many threads suits best for the decoding job + mVideoCodecContext->thread_count = 0; + + if (mVideoCodec->capabilities | AV_CODEC_CAP_FRAME_THREADS) { + mVideoCodecContext->thread_type = FF_THREAD_FRAME; + } else if (mVideoCodec->capabilities | AV_CODEC_CAP_SLICE_THREADS) { + mVideoCodecContext->thread_type = FF_THREAD_SLICE; + } else { + mVideoCodecContext->thread_count = 1; //don't use multithreading + } + ret = avcodec_open2(mVideoCodecContext, mVideoCodec, &opts); e = nullptr; From c37d8eeded5e5c7562537de64b76f59d9d318e1e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 17 Nov 2021 17:45:38 -0500 Subject: [PATCH 2/2] spacing and report save errors --- web/includes/actions/monitors.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/web/includes/actions/monitors.php b/web/includes/actions/monitors.php index 118af1533..c133ac83b 100644 --- a/web/includes/actions/monitors.php +++ b/web/includes/actions/monitors.php @@ -19,24 +19,27 @@ // // Monitor edit actions, monitor id derived, require edit permissions for that monitor -if ( ! canEdit('Monitors') ) { +if (!canEdit('Monitors')) { ZM\Warning("Monitor actions require Monitors Permissions"); return; } -if ( $action == 'save' ) { - foreach ( $_REQUEST['mids'] as $mid ) { +if ($action == 'save') { + foreach ($_REQUEST['mids'] as $mid) { $mid = ValidInt($mid); - if ( ! canEdit('Monitors', $mid) ) { - ZM\Warning("Cannot edit monitor $mid"); + if (!canEdit('Monitors', $mid)) { + ZM\Warning('Cannot edit monitor '.$mid); continue; } $Monitor = new ZM\Monitor($mid); - if ( $Monitor->Type() != 'WebSite' ) { + if ($Monitor->Type() != 'WebSite') { $Monitor->zmcControl('stop'); } - $Monitor->save($_REQUEST['newMonitor']); - if ( $Monitor->Function() != 'None' && $Monitor->Type() != 'WebSite' ) { + if (!$Monitor->save($_REQUEST['newMonitor'])) { + global $error_message; + $error_message .= 'Error saving monitor: ' . $Monitor->get_last_error().'
'; + } + if ($Monitor->Function() != 'None' && $Monitor->Type() != 'WebSite') { $Monitor->zmcControl('start'); } } // end foreach mid