Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust nginx proc count based on available CPUs #11653

Merged
merged 5 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ set -o errexit -o nounset -o pipefail

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
exec 2>&1
exec nginx
4 changes: 3 additions & 1 deletion frigate/events/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ def get_ffmpeg_command(ffmpeg: FfmpegConfig) -> list[str]:
or get_ffmpeg_arg_list(ffmpeg.input_args)
)
return (
["ffmpeg", "-vn"]
["ffmpeg", "-vn", "-threads", "1"]
+ input_args
+ ["-i"]
+ [ffmpeg_input.path]
+ [
"-threads",
"1",
"-f",
f"{AUDIO_FORMAT}",
"-ar",
Expand Down
4 changes: 4 additions & 0 deletions frigate/output/birdseye.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def __init__(

ffmpeg_cmd = [
"ffmpeg",
"-threads",
"1",
"-f",
"rawvideo",
"-pix_fmt",
Expand All @@ -142,6 +144,8 @@ def __init__(
f"{in_width}x{in_height}",
"-i",
"pipe:",
"-threads",
"1",
"-f",
"mpegts",
"-s",
Expand Down
4 changes: 4 additions & 0 deletions frigate/output/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def __init__(

ffmpeg_cmd = [
"ffmpeg",
"-threads",
"1",
"-f",
"rawvideo",
"-pix_fmt",
Expand All @@ -39,6 +41,8 @@ def __init__(
f"{in_width}x{in_height}",
"-i",
"pipe:",
"-threads",
"1",
"-f",
"mpegts",
"-s",
Expand Down
14 changes: 13 additions & 1 deletion web/src/components/player/VideoControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ export default function VideoControls({
const onKeyboardShortcut = useCallback(
(key: string, down: boolean, repeat: boolean) => {
switch (key) {
case "ArrowDown":
if (down) {
onSeek(-1);
}
break;
case "ArrowLeft":
if (down) {
onSeek(-10);
Expand All @@ -149,6 +154,11 @@ export default function VideoControls({
onSeek(10);
}
break;
case "ArrowUp":
if (down) {
onSeek(1);
}
break;
case "f":
if (setFullscreen && down && !repeat) {
setFullscreen(!fullscreen);
Expand All @@ -171,7 +181,9 @@ export default function VideoControls({
[video, isPlaying, fullscreen, setFullscreen, onSeek],
);
useKeyboardListener(
hotKeys ? ["ArrowLeft", "ArrowRight", "f", "m", " "] : [],
hotKeys
? ["ArrowDown", "ArrowLeft", "ArrowRight", "ArrowUp", "f", "m", " "]
: [],
onKeyboardShortcut,
);

Expand Down
Loading