Skip to content

Commit 32a4cd2

Browse files
authored
frigate: pin joserfc at 1.1.0; ffmpeg flavor selection (#438285)
2 parents 221449e + 6c4b180 commit 32a4cd2

File tree

3 files changed

+52
-24
lines changed

3 files changed

+52
-24
lines changed

nixos/modules/services/video/frigate.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,17 @@ in
231231
};
232232
};
233233

234+
ffmpeg = {
235+
path = mkOption {
236+
type = coercedTo package toString str;
237+
default = pkgs.ffmpeg-headless;
238+
example = literalExpression "pkgs.ffmpeg-full";
239+
description = ''
240+
Package providing the ffmpeg and ffprobe executables below the bin/ directory.
241+
'';
242+
};
243+
};
244+
234245
mqtt = {
235246
enabled = mkEnableOption "MQTT support";
236247

pkgs/by-name/fr/frigate/ffmpeg.patch

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
11
diff --git a/frigate/config/camera/ffmpeg.py b/frigate/config/camera/ffmpeg.py
2-
index 04bbfac7..4390a571 100644
2+
index 04bbfac7..396bcc4b 100644
33
--- a/frigate/config/camera/ffmpeg.py
44
+++ b/frigate/config/camera/ffmpeg.py
5-
@@ -70,18 +70,14 @@ class FfmpegConfig(FrigateBaseModel):
5+
@@ -1,4 +1,5 @@
6+
from enum import Enum
7+
+from os.path import join
8+
from typing import Union
9+
10+
from pydantic import Field, field_validator
11+
@@ -69,21 +70,11 @@ class FfmpegConfig(FrigateBaseModel):
12+
613
@property
714
def ffmpeg_path(self) -> str:
8-
if self.path == "default":
15+
- if self.path == "default":
916
- return f"/usr/lib/ffmpeg/{DEFAULT_FFMPEG_VERSION}/bin/ffmpeg"
1017
- elif self.path in INCLUDED_FFMPEG_VERSIONS:
1118
- return f"/usr/lib/ffmpeg/{self.path}/bin/ffmpeg"
12-
+ return "@ffmpeg@"
13-
else:
14-
return f"{self.path}/bin/ffmpeg"
19+
- else:
20+
- return f"{self.path}/bin/ffmpeg"
21+
+ return join(self.path, "bin/ffmpeg")
1522

1623
@property
1724
def ffprobe_path(self) -> str:
18-
if self.path == "default":
25+
- if self.path == "default":
1926
- return f"/usr/lib/ffmpeg/{DEFAULT_FFMPEG_VERSION}/bin/ffprobe"
2027
- elif self.path in INCLUDED_FFMPEG_VERSIONS:
2128
- return f"/usr/lib/ffmpeg/{self.path}/bin/ffprobe"
22-
+ return "@ffprobe@"
23-
else:
24-
return f"{self.path}/bin/ffprobe"
29+
- else:
30+
- return f"{self.path}/bin/ffprobe"
31+
+ return join(self.path, "bin/ffprobe")
32+
2533

34+
class CameraRoleEnum(str, Enum):
2635
diff --git a/frigate/record/export.py b/frigate/record/export.py
27-
index 0d3f96da..09cadbcd 100644
36+
index 0d3f96da..463bcff4 100644
2837
--- a/frigate/record/export.py
2938
+++ b/frigate/record/export.py
3039
@@ -126,7 +126,7 @@ class RecordingExporter(threading.Thread):
3140
minutes = int(diff / 60)
3241
seconds = int(diff % 60)
3342
ffmpeg_cmd = [
3443
- "/usr/lib/ffmpeg/7.0/bin/ffmpeg", # hardcode path for exports thumbnail due to missing libwebp support
35-
+ "@ffmpeg@", # hardcode path for exports thumbnail due to missing libwebp support
44+
+ FfmpegConfig.ffmpeg_path, # hardcode path for exports thumbnail due to missing libwebp support
3645
"-hide_banner",
3746
"-loglevel",
3847
"warning",
39-
~

pkgs/by-name/fr/frigate/package.nix

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
lib,
33
stdenv,
44
callPackage,
5-
replaceVars,
65
python312Packages,
76
fetchFromGitHub,
87
fetchurl,
@@ -27,7 +26,20 @@ let
2726
inherit version src;
2827
};
2928

30-
python = python312Packages.python;
29+
python = python312Packages.python.override {
30+
packageOverrides = self: super: {
31+
joserfc = super.joserfc.overridePythonAttrs (oldAttrs: {
32+
version = "1.1.0";
33+
src = fetchFromGitHub {
34+
owner = "authlib";
35+
repo = "joserfc";
36+
tag = version;
37+
hash = "sha256-95xtUzzIxxvDtpHX/5uCHnTQTB8Fc08DZGUOR/SdKLs=";
38+
};
39+
});
40+
};
41+
};
42+
python3Packages = python.pkgs;
3143

3244
# Tensorflow audio model
3345
# https://github.com/blakeblackshear/frigate/blob/v0.15.0/docker/main/Dockerfile#L125
@@ -56,7 +68,7 @@ let
5668
hash = "sha256-5Cj2vEiWR8Z9d2xBmVoLZuNRv4UOuxHSGZQWTJorXUQ=";
5769
};
5870
in
59-
python312Packages.buildPythonApplication rec {
71+
python3Packages.buildPythonApplication rec {
6072
pname = "frigate";
6173
inherit version;
6274
format = "other";
@@ -65,11 +77,7 @@ python312Packages.buildPythonApplication rec {
6577

6678
patches = [
6779
./constants.patch
68-
69-
(replaceVars ./ffmpeg.patch {
70-
ffmpeg = lib.getExe ffmpeg-headless;
71-
ffprobe = lib.getExe' ffmpeg-headless "ffprobe";
72-
})
80+
./ffmpeg.patch
7381
];
7482

7583
postPatch = ''
@@ -109,7 +117,7 @@ python312Packages.buildPythonApplication rec {
109117

110118
dontBuild = true;
111119

112-
dependencies = with python312Packages; [
120+
dependencies = with python3Packages; [
113121
# docker/main/requirements.txt
114122
scikit-build
115123
# docker/main/requirements-wheel.txt
@@ -191,7 +199,8 @@ python312Packages.buildPythonApplication rec {
191199
runHook postInstall
192200
'';
193201

194-
nativeCheckInputs = with python312Packages; [
202+
nativeCheckInputs = with python3Packages; [
203+
ffmpeg-headless
195204
pytestCheckHook
196205
];
197206

@@ -213,7 +222,7 @@ python312Packages.buildPythonApplication rec {
213222
passthru = {
214223
web = frigate-web;
215224
inherit python;
216-
pythonPath = (python312Packages.makePythonPath dependencies) + ":${frigate}/${python.sitePackages}";
225+
pythonPath = (python3Packages.makePythonPath dependencies) + ":${frigate}/${python.sitePackages}";
217226
tests = {
218227
inherit (nixosTests) frigate;
219228
};

0 commit comments

Comments
 (0)