blob: 62d2531c2b3a9b859ea22ce211b7c514bacfcf2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{ me, ... }:
let
ffmpegDevice =
device: format: resolution: hz: options:
"ffmpeg:device?video=${device}&input_format=${format}&video_size=${resolution}&framerate=${hz}${options}";
go2rtcPort = 1984;
webrtcPort = 8555;
in
{
services.go2rtc = {
enable = true;
settings = {
api = {
listen = "${me.tailscale.ip}:${toString go2rtcPort}";
base_path = "/webcam";
origin = "*"; # stop cors annoyance!
};
webrtc =
let
address = "${me.tailscale.ip}:${toString webrtcPort}";
in
{
listen = address;
candidates = [ address ];
};
streams = {
cam1-yuyv422 = ffmpegDevice "/dev/video0" "yuyv422" "1280x960" "30" "#video=h264#hardware";
# todo: i think ffmpeg still currently reencodes the mjpeg again,
# but with video=copy all i get back are corrupted frames.
cam1-mjpeg = ffmpegDevice "/dev/video0" "mjpeg" "1280x960" "30" "";
};
};
};
foundation.tailnetServices = [ "go2rtc" ];
}
|