mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
chore(motion): update settings
This commit is contained in:
parent
aa6f6587a6
commit
64d302abec
6 changed files with 48 additions and 14 deletions
|
|
@ -110,13 +110,11 @@ in
|
|||
};
|
||||
config.services.motion = let
|
||||
configFile = pkgs.writeText "motion.conf" cfg.configText;
|
||||
enableIPv6 = mkIf config.networking.enableIPv6 (mkOptionDefault true);
|
||||
enabledCameras = filter (camera: camera.enable) (attrValues cfg.cameras);
|
||||
in {
|
||||
settings = {
|
||||
target_dir = mkOptionDefault cfg.dataDir;
|
||||
ipv6_enabled = enableIPv6;
|
||||
webcontrol_ipv6 = enableIPv6;
|
||||
webcontrol_ipv6 = mkIf config.networking.enableIPv6 (mkOptionDefault true);
|
||||
};
|
||||
configFile = mkOptionDefault "${configFile}";
|
||||
configText = mkMerge (
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
access,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkDefault;
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (config.services) nginx;
|
||||
system = access.systemForServiceId "kitchen";
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
in {
|
||||
config.services.nginx = {
|
||||
virtualHosts = let
|
||||
# TODO: use upstreams for this!
|
||||
url = access.proxyUrlFor {
|
||||
inherit system;
|
||||
service = motion;
|
||||
|
|
@ -21,6 +22,9 @@ in {
|
|||
service = motion;
|
||||
portName = "stream";
|
||||
};
|
||||
mkSubFilter = port: ''
|
||||
sub_filter '${port.protocol}://kitchen.local.gensokyo.zone:${toString port.port}/' '/';
|
||||
'';
|
||||
extraConfig = ''
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
|
|
@ -28,6 +32,11 @@ in {
|
|||
locations = {
|
||||
"/" = {
|
||||
proxyPass = mkDefault url;
|
||||
extraConfig = ''
|
||||
sub_filter_once off;
|
||||
${mkSubFilter motion.ports.stream}
|
||||
${mkSubFilter motion.ports.default}
|
||||
'';
|
||||
};
|
||||
"~ ^/[0-9]+/(stream|motion|substream|current|source|status\\.json)$" = {
|
||||
proxyPass = mkDefault streamUrl;
|
||||
|
|
@ -42,7 +51,8 @@ in {
|
|||
http = {};
|
||||
https.ssl = true;
|
||||
stream = {
|
||||
enable = mkDefault motion.ports.stream.enable;
|
||||
enable = false;
|
||||
#enable = mkDefault motion.ports.stream.enable;
|
||||
port = mkDefault motion.ports.stream.port;
|
||||
};
|
||||
};
|
||||
|
|
@ -67,7 +77,7 @@ in {
|
|||
};
|
||||
config.networking.firewall.allowedTCPPorts = let
|
||||
inherit (nginx.virtualHosts.kitchencam) listen';
|
||||
in [
|
||||
in mkIf listen'.stream.enable [
|
||||
listen'.stream.port
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,24 @@
|
|||
}: let
|
||||
inherit (gensokyo-zone.lib) mapDefaults;
|
||||
inherit (config.services) motion;
|
||||
in {
|
||||
services.motion.cameras.kitchencam.settings = mapDefaults {
|
||||
videodevice = "/dev/kitchencam";
|
||||
video_params = "auto_brightness=2,palette=8"; # MJPG=8, YUYV=15
|
||||
format = "mjpeg"; # or "yuyv"
|
||||
params = {
|
||||
mjpeg = {
|
||||
palette = 8;
|
||||
width = 1280;
|
||||
height = 720;
|
||||
};
|
||||
yuyv = {
|
||||
palette = 15;
|
||||
width = 640;
|
||||
height = 480;
|
||||
};
|
||||
};
|
||||
in {
|
||||
services.motion.cameras.kitchencam.settings = mapDefaults {
|
||||
video_device = "/dev/kitchencam";
|
||||
video_params = "auto_brightness=2,palette=${toString params.${format}.palette}";
|
||||
inherit (params.${format}) width height;
|
||||
framerate = 2;
|
||||
camera_id = 1;
|
||||
text_left = "kitchen";
|
||||
|
|
|
|||
|
|
@ -2,8 +2,12 @@
|
|||
inherit (gensokyo-zone.lib) mapDefaults;
|
||||
in {
|
||||
services.motion.cameras.webcam.settings = mapDefaults {
|
||||
videodevice = "/dev/video0";
|
||||
video_device = "/dev/video0";
|
||||
video_params = "palette=15";
|
||||
width = 1280;
|
||||
height = 720;
|
||||
camera_id = 3;
|
||||
framerate = 3;
|
||||
text_left = "logistics";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@
|
|||
inherit (config.services) motion;
|
||||
in {
|
||||
services.motion.cameras.printercam.settings = mapDefaults {
|
||||
videodevice = "/dev/printercam";
|
||||
video_device = "/dev/printercam";
|
||||
video_params = "auto_brightness=1,palette=8"; # MJPG=8, YUYV=15
|
||||
width = 1920;
|
||||
height = 1080;
|
||||
framerate = 2;
|
||||
framerate = 4;
|
||||
camera_id = 2;
|
||||
text_left = "";
|
||||
#text_right = "";
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ in {
|
|||
movie_output = false;
|
||||
picture_filename = "%Y%m%d%H%M%S-%q";
|
||||
movie_filename = "%t-%v-%Y%m%d%H%M%S";
|
||||
movie_passthrough = true;
|
||||
pause = true;
|
||||
|
||||
text_right = "%Y-%m-%d\\n%T-%q";
|
||||
emulate_motion = false;
|
||||
threshold = 1500;
|
||||
despeckle_filter = "EedDl";
|
||||
minimum_motion_frames = 1;
|
||||
|
|
@ -33,8 +34,17 @@ in {
|
|||
webcontrol_parms = 0;
|
||||
webcontrol_port = webPort;
|
||||
stream_port = streamPort;
|
||||
|
||||
stream_maxrate = 30;
|
||||
stream_quality = 75;
|
||||
};
|
||||
};
|
||||
systemd.services.motion = mkIf cfg.enable {
|
||||
serviceConfig.LogFilterPatterns = [
|
||||
''~Corrupt image \.\.\. continue''
|
||||
''~Invalid JPEG file structure: missing SOS marker''
|
||||
];
|
||||
};
|
||||
networking.firewall.interfaces.local = mkIf cfg.enable {
|
||||
allowedTCPPorts = [cfg.settings.stream_port cfg.settings.webcontrol_port];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue