mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Adjust nginx proc count based on available CPUs (#11653)
* Restrict nginx to 4 processes if more are available * Fix bash * Different sed structure * Limit ffmpeg thread counts for secondary ffmpeg processes * Add up / down keyboard shortcut
This commit is contained in:
parent
402c16e7df
commit
142641b387
@ -8,6 +8,19 @@ set -o errexit -o nounset -o pipefail
|
|||||||
|
|
||||||
echo "[INFO] Starting NGINX..."
|
echo "[INFO] Starting NGINX..."
|
||||||
|
|
||||||
|
function set_worker_processes() {
|
||||||
|
# Capture number of assigned CPUs to calculate worker processes
|
||||||
|
local proc_count
|
||||||
|
|
||||||
|
if proc_count=$(nproc --all) && [[ $proc_count -gt 4 ]]; then
|
||||||
|
proc_count=4;
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i "s/worker_processes auto;/worker_processes ${proc_count};/" /usr/local/nginx/conf/nginx.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
set_worker_processes
|
||||||
|
|
||||||
# Replace the bash process with the NGINX process, redirecting stderr to stdout
|
# Replace the bash process with the NGINX process, redirecting stderr to stdout
|
||||||
exec 2>&1
|
exec 2>&1
|
||||||
exec nginx
|
exec nginx
|
||||||
|
@ -50,11 +50,13 @@ def get_ffmpeg_command(ffmpeg: FfmpegConfig) -> list[str]:
|
|||||||
or get_ffmpeg_arg_list(ffmpeg.input_args)
|
or get_ffmpeg_arg_list(ffmpeg.input_args)
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
["ffmpeg", "-vn"]
|
["ffmpeg", "-vn", "-threads", "1"]
|
||||||
+ input_args
|
+ input_args
|
||||||
+ ["-i"]
|
+ ["-i"]
|
||||||
+ [ffmpeg_input.path]
|
+ [ffmpeg_input.path]
|
||||||
+ [
|
+ [
|
||||||
|
"-threads",
|
||||||
|
"1",
|
||||||
"-f",
|
"-f",
|
||||||
f"{AUDIO_FORMAT}",
|
f"{AUDIO_FORMAT}",
|
||||||
"-ar",
|
"-ar",
|
||||||
|
@ -134,6 +134,8 @@ class FFMpegConverter(threading.Thread):
|
|||||||
|
|
||||||
ffmpeg_cmd = [
|
ffmpeg_cmd = [
|
||||||
"ffmpeg",
|
"ffmpeg",
|
||||||
|
"-threads",
|
||||||
|
"1",
|
||||||
"-f",
|
"-f",
|
||||||
"rawvideo",
|
"rawvideo",
|
||||||
"-pix_fmt",
|
"-pix_fmt",
|
||||||
@ -142,6 +144,8 @@ class FFMpegConverter(threading.Thread):
|
|||||||
f"{in_width}x{in_height}",
|
f"{in_width}x{in_height}",
|
||||||
"-i",
|
"-i",
|
||||||
"pipe:",
|
"pipe:",
|
||||||
|
"-threads",
|
||||||
|
"1",
|
||||||
"-f",
|
"-f",
|
||||||
"mpegts",
|
"mpegts",
|
||||||
"-s",
|
"-s",
|
||||||
|
@ -31,6 +31,8 @@ class FFMpegConverter(threading.Thread):
|
|||||||
|
|
||||||
ffmpeg_cmd = [
|
ffmpeg_cmd = [
|
||||||
"ffmpeg",
|
"ffmpeg",
|
||||||
|
"-threads",
|
||||||
|
"1",
|
||||||
"-f",
|
"-f",
|
||||||
"rawvideo",
|
"rawvideo",
|
||||||
"-pix_fmt",
|
"-pix_fmt",
|
||||||
@ -39,6 +41,8 @@ class FFMpegConverter(threading.Thread):
|
|||||||
f"{in_width}x{in_height}",
|
f"{in_width}x{in_height}",
|
||||||
"-i",
|
"-i",
|
||||||
"pipe:",
|
"pipe:",
|
||||||
|
"-threads",
|
||||||
|
"1",
|
||||||
"-f",
|
"-f",
|
||||||
"mpegts",
|
"mpegts",
|
||||||
"-s",
|
"-s",
|
||||||
|
@ -139,6 +139,11 @@ export default function VideoControls({
|
|||||||
const onKeyboardShortcut = useCallback(
|
const onKeyboardShortcut = useCallback(
|
||||||
(key: string, down: boolean, repeat: boolean) => {
|
(key: string, down: boolean, repeat: boolean) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case "ArrowDown":
|
||||||
|
if (down) {
|
||||||
|
onSeek(-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
if (down) {
|
if (down) {
|
||||||
onSeek(-10);
|
onSeek(-10);
|
||||||
@ -149,6 +154,11 @@ export default function VideoControls({
|
|||||||
onSeek(10);
|
onSeek(10);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "ArrowUp":
|
||||||
|
if (down) {
|
||||||
|
onSeek(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "f":
|
case "f":
|
||||||
if (setFullscreen && down && !repeat) {
|
if (setFullscreen && down && !repeat) {
|
||||||
setFullscreen(!fullscreen);
|
setFullscreen(!fullscreen);
|
||||||
@ -171,7 +181,9 @@ export default function VideoControls({
|
|||||||
[video, isPlaying, fullscreen, setFullscreen, onSeek],
|
[video, isPlaying, fullscreen, setFullscreen, onSeek],
|
||||||
);
|
);
|
||||||
useKeyboardListener(
|
useKeyboardListener(
|
||||||
hotKeys ? ["ArrowLeft", "ArrowRight", "f", "m", " "] : [],
|
hotKeys
|
||||||
|
? ["ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", "f", "m", " "]
|
||||||
|
: [],
|
||||||
onKeyboardShortcut,
|
onKeyboardShortcut,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user