Last modified by Normann P. Nielsen on 2025/02/12 19:58

Show last authors
1 {{success}}Do also read [[Making a simple NVR (Frigate) Alternative>>Main.information-technology.making-a-simple-nvr-frigate-alternative]]{{/success}}
2
3
4
5 So, I got hands on a older MacBook and it seemed fit according to the [[Recommended Hardware>>https://docs.frigate.video/frigate/hardware]].
6
7 Also, I am equipped with 4 Reolink Cams and a [[Coral stick>>https://coral.ai/products/accelerator/]], but I have not used any Reolink specifics from [[Camera Specific Configuration>>https://docs.frigate.video/configuration/camera_specific]].
8
9 And of cause, I have a Home Assistant installation running.
10
11
12
13 {{toc/}}
14
15 = Preparing the MacBook Firmware/T2 =
16
17 I had some problems with removing the [[activation lock>>https://support.apple.com/en-us/HT201365]] and even do an Internet recovery (that just failed with 1008F Error). but when the MACOS finally was cleanly installed, make sure to enable USB Boot, as this:
18
19 [[image:image-20181128060256-2.png||alt="image-20181128060256-2.png"]]
20
21 = Installing Ubuntu =
22
23 I had a lot of trouble actually getting the danm thing to boot, but on a stick with Ubuntu 22.04 (used [[Balena Etcher>>https://etcher.balena.io/]]), it finally did.
24
25 But, the Mac Keyboard was not working, but I got hold of an eternal keyboard - and that worked.
26
27 **I had a lot of problemes getting to use the disk**, several times the installer just crashed and restarted, or stopped with "Installing grub on taget device failed"
28
29 But I finally got the installer to **remove all partitions** and install, with the "Use custom partitions" option - **make sure to whipe and erase all partitions on the disk**.
30
31 After the install the "df -h" command told me that only 100 GB of the disk was used - I have no clue why the installer sets it up this way..
32
33 But the fix was easy - first examine the LVM:
34
35
36 {{code}}
37 root@beetle:/home/bnp# vgdisplay
38 --- Volume group ---
39 VG Name ubuntu-vg
40 System ID
41 Format lvm2
42 Metadata Areas 1
43 Metadata Sequence No 2
44 VG Access read/write
45 VG Status resizable
46 MAX LV 0
47 Cur LV 1
48 Open LV 1
49 Max PV 0
50 Cur PV 1
51 Act PV 1
52 VG Size <462.87 GiB
53 PE Size 4.00 MiB
54 Total PE 118494
55 Alloc PE / Size 25600 / 100.00 GiB
56 Free PE / Size 92894 / <362.87 GiB
57 VG UUID Dd5nRh-qzsj-z6rX-H1o1-JzMd-kXEI-7bWoEx
58
59 {{/code}}
60
61 The import part being:
62
63
64 {{code}}
65 Free PE / Size 92894 / <362.87 GiB
66 {{/code}}
67
68 So, 362 GB not used.
69
70 Lets extend and resize:
71
72
73 {{code}}
74 lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
75 resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
76 {{/code}}
77
78
79
80 Now, we can see "Free PE / Size 0 / 0"
81
82
83 {{code}}
84 root@beetle:/home/bnp# vgdisplay
85 --- Volume group ---
86 VG Name ubuntu-vg
87 System ID
88 Format lvm2
89 Metadata Areas 1
90 Metadata Sequence No 4
91 VG Access read/write
92 VG Status resizable
93 MAX LV 0
94 Cur LV 1
95 Open LV 1
96 Max PV 0
97 Cur PV 1
98 Act PV 1
99 VG Size <462.87 GiB
100 PE Size 4.00 MiB
101 Total PE 118494
102 Alloc PE / Size 118494 / <462.87 GiB
103 Free PE / Size 0 / 0
104 VG UUID Dd5nRh-qzsj-z6rX-H1o1-JzMd-kXEI-7bWoEx
105 {{/code}}
106
107 Ubuntu is installed and the complete SSD Disk is now utilized.
108
109 = Docker install =
110
111 Lets install docker.io:
112
113
114 {{code}}
115 apt install docker.io
116 {{/code}}
117
118
119
120 = Frigate NVR Install =
121
122 Find information on Frigate [[here>>https://frigate.video/]]
123
124 {{success}}First, I generally put all docker stuff in /opt - and I dont use docker-compose very much. Maybee one day...{{/success}}
125
126
127
128 Creating the needed Directory and the config file:
129
130
131 {{code}}
132 mkdir /opt/frigate
133 vi /opt/frigate/config
134 {{/code}}
135
136
137
138 The config file can be huge and there are plenty of options, here is my **current**:
139
140
141 {{code}}
142 mqtt:
143 host: 10.0.0.183
144 go2rtc:
145 streams:
146 frigate_front_door_cam_main:
147 - "ffmpeg:http://10.0.0.151/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=******&password=******#video=copy#audio=copy#audio=opus"
148 frigate_front_door_cam_sub:
149 - "ffmpeg:http://10.0.0.151/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=******&password=******"
150 frigate_behind_house_cam_main:
151 - "ffmpeg:http://10.0.0.176/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=******&password=******#video=copy#audio=copy#audio=opus"
152 frigate_behind_house_cam_sub:
153 - "ffmpeg:http://10.0.0.176/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=******&password=******"
154 frigate_carport_cam_main:
155 - "ffmpeg:http://10.0.0.191/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=******&password=******#video=copy#audio=copy#audio=opus"
156 frigate_carport_cam_sub:
157 - "ffmpeg:http://10.0.0.191/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=******&password=******"
158 frigate_big_shed_cam_main:
159 - "ffmpeg:http://10.0.0.108/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=******&password=******#video=copy#audio=copy#audio=opus"
160 frigate_big_shed_cam_sub:
161 - "ffmpeg:http://10.0.0.108/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=******&password=******"
162
163 cameras:
164 frigate_front_door_cam:
165 ffmpeg:
166 inputs:
167 - path: rtsp://127.0.0.1:8554/frigate_front_door_cam_sub?video=copy
168 input_args: preset-rtsp-restream
169 roles:
170 - detect
171 - path: rtsp://127.0.0.1:8554/frigate_front_door_cam_main?video=copy&audio=aac
172 input_args: preset-rtsp-restream
173 roles:
174 - record
175 rtmp:
176 enabled: False
177 detect:
178 width: 640
179 height: 480
180 fps: 5
181 objects:
182 track:
183 - person
184 snapshots:
185 enabled: True
186 timestamp: false
187 bounding_box: True
188 retain:
189 default: 2
190 record:
191 enabled: True
192 events:
193 retain:
194 default: 10
195 frigate_behind_house_cam:
196 ffmpeg:
197 inputs:
198 - path: rtsp://127.0.0.1:8554/frigate_behind_house_cam_sub?video=copy
199 input_args: preset-rtsp-restream
200 roles:
201 - detect
202 - path: rtsp://127.0.0.1:8554/frigate_behind_house_cam_main?video=copy&audio=aac
203 input_args: preset-rtsp-restream
204 roles:
205 - record
206 rtmp:
207 enabled: False
208 detect:
209 width: 640
210 height: 480
211 fps: 5
212 objects:
213 track:
214 - person
215 snapshots:
216 enabled: True
217 timestamp: false
218 bounding_box: True
219 retain:
220 default: 2
221 record:
222 enabled: True
223 events:
224 retain:
225 default: 10
226 frigate_carport_cam:
227 ffmpeg:
228 inputs:
229 - path: rtsp://127.0.0.1:8554/frigate_carport_cam_sub?video=copy
230 input_args: preset-rtsp-restream
231 roles:
232 - detect
233 - path: rtsp://127.0.0.1:8554/frigate_carport_cam_main?video=copy&audio=aac
234 input_args: preset-rtsp-restream
235 roles:
236 - record
237 rtmp:
238 enabled: False
239 detect:
240 width: 640
241 height: 480
242 fps: 5
243 objects:
244 track:
245 - person
246 - car
247 snapshots:
248 enabled: True
249 timestamp: false
250 bounding_box: True
251 retain:
252 default: 2
253 record:
254 enabled: True
255 events:
256 retain:
257 default: 10
258 frigate_big_shed_cam:
259 ffmpeg:
260 inputs:
261 - path: rtsp://127.0.0.1:8554/frigate_big_shed_cam_sub?video=copy
262 input_args: preset-rtsp-restream
263 roles:
264 - detect
265 - path: rtsp://127.0.0.1:8554/frigate_big_shed_cam_main?video=copy&audio=aac
266 input_args: preset-rtsp-restream
267 roles:
268 - record
269 rtmp:
270 enabled: False
271 detect:
272 width: 640
273 height: 480
274 fps: 5
275 objects:
276 track:
277 - person
278 - car
279 snapshots:
280 enabled: True
281 timestamp: false
282 bounding_box: True
283 retain:
284 default: 2
285 record:
286 enabled: True
287 events:
288 retain:
289 default: 10
290 detectors:
291 coral:
292 type: edgetpu
293 device: usb
294 birdseye:
295 enabled: True
296 mode: continuous
297 {{/code}}
298
299
300
301 {{success}}In short, the file sets up 4 cams - using:
302
303 * go2rtc as "proxy" - **this made a huge difference and improvement **(I** **started using RTSP streams directly into frigate, and the recorded videos lagged and was sometimes broken). See [[https://docs.frigate.video/guides/configuring_go2rtc]]
304 * The Lowres RTSP stream (sub) for the Detect role as generally recommended, as frigate only uses a 300x300 pixel image for object detection. See [[https://docs.frigate.video/frigate/camera_setup]]
305 * The highres RTSP stream (main) for the Recording Role as generally recommended.
306 * input_args: preset-rtsp-restream as recommedded for Reolink (see [[https://docs.frigate.video/configuration/camera_specific]])
307 * Recording event on object detection
308 * Take snapshots on event
309 * The tracking of persons and cars
310 * The use of a Coral stick for Object processing - instead of the CPU{{/success}}
311
312 Reference to the configuration file is [[here>>https://docs.frigate.video/configuration/]].
313
314 And the database file /opt/frigate/frigate.yml
315
316
317 {{code}}
318 codedatabase:
319 path: /opt/frigate/frigate.db
320 {{/code}}
321
322
323
324 Now we can start Frigate:
325
326
327 {{code}}
328 docker run -d \
329 --name frigate \
330 --restart always \
331 --mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
332 --device /dev/bus/usb:/dev/bus/usb \
333 --shm-size=256m \
334 -v /opt/frigate/media:/media/frigate \
335 -v /opt/frigate/config.yml:/config/config.yml:ro \
336 -v /etc/localtime:/etc/localtime:ro \
337 -e FRIGATE_RTSP_PASSWORD='**********' \
338 -p 5000:5000 \
339 -p 1935:1935 \
340   ghcr.io/blakeblackshear/frigate:stable
341 {{/code}}
342
343
344
345 This should start Frigate and show it on http://10.0.0.164:5000:
346
347 [[image:Screen Shot 2023-08-28 at 19.34.14.jpg||width="1000"||alt="Screen Shot 2023-08-28 at 19.34.14.jpg"]]
348
349
350
351 If the interface **is not up**, troubleshoot the logs with:
352
353
354 {{code}}
355 docker logs --tail 50 --follow --timestamps "frigate"
356 {{/code}}
357
358
359
360 Heres a view on object detection:
361
362 [[image:Screenshot 2023-08-28 at 20.15.19.png||width="1000"||alt="Screenshot 2023-08-28 at 20.15.19.png"]]
363
364 And a snapshot with an object detection (the yellow box is the bounding_box in the config file):
365
366 [[image:Screenshot 2023-08-28 at 20.23.13.png||height="400"||alt="Screenshot 2023-08-28 at 20.23.13.png"]]
367
368 = Coral Stick on Linux =
369
370 I had some problems getting the [[Coral stick>>https://coral.ai/products/accelerator/]] to work (the Frigate docker image has all needed for it), but it did not show up as an Device on the MacBook:
371
372
373 {{code}}
374 root@beetle:/home/bnp# lsusb
375 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
376 Bus 001 Device 003: ID 05ac:1463 Apple, Inc. USB-C Digital AV Multiport Adapter
377 Bus 001 Device 002: ID 05ac:1017 Apple, Inc. USB2.0 Hub
378 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
379 Bus 006 Device 002: ID 05ac:1018 Apple, Inc. USB3.1 Hub
380 Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
381 Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
382 Bus 004 Device 002: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
383 Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
384 Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
385 {{/code}}
386
387
388
389 Loking at the links for the 2 versions - [[USB>>https://coral.ai/docs/accelerator/get-started/#requirements]] and [[M2>>https://coral.ai/docs/m2/get-started/#2a-on-linux]]
390
391
392 {{code}}
393 echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
394 curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
395 sudo apt-get update
396 sudo apt-get install gasket-dkms libedgetpu1-std
397 {{/code}}
398
399 So it seems my stick is detected as a PCI Device. Theres some more info on what to use as docker parameter [[here>>https://docs.frigate.video/frigate/installation]]:
400
401
402 {{code}}
403 - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
404 - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
405 - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
406 {{/code}}
407
408
409
410 And now its visible:
411
412
413 {{code}}
414 root@beetle:/home/bnp# lsusb
415 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
416 Bus 001 Device 003: ID 05ac:1463 Apple, Inc. USB-C Digital AV Multiport Adapter
417 Bus 001 Device 002: ID 05ac:1017 Apple, Inc. USB2.0 Hub
418 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
419 Bus 006 Device 003: ID 1a6e:089a Global Unichip Corp.
420 Bus 006 Device 002: ID 05ac:1018 Apple, Inc. USB3.1 Hub
421 Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
422 Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
423 Bus 004 Device 002: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
424 Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
425 Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
426 {{/code}}