Sidehistorik
So, I purchased an older MacBook from work - that has been my own for 4 year, and got hands on a older MacBook and it seemed fit according to the Recommended Hardware.
Also, I am equipped with 4 Reolink Cams and a Coral stick, but I have not used any reolink Reolink specifics from Camera Specific Configuration.
And of cause, I have a Home Assistant installation running.
Indholdsfortegnelse |
---|
Preparing the MacBook Firmware/T2
I had some problems with removing the activation lock 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:
Installing Ubuntu
I had a lot of trouble actually getting the danm thing to boot, but on a stick with Ubuntu 22.04 (used Balena Etcher), it finally did.
...
I had a lot of problemes getting to use the disk, several times the installer just crashed and restarted, and or stopped with "Installing grub on taget device failed"
But I finally got the installer to r emove remove all partitions and install, with the "Use custom partitions" option - make sure to whipe and erase all partitions on the disk.
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..
But the fix was eady easy - first examine the LVM:
Kodeblok |
---|
root@beetle:/home/bnp# vgdisplay --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <462.87 GiB PE Size 4.00 MiB Total PE 118494 Alloc PE / Size 25600 / 100.00 GiB Free PE / Size 92894 / <362.87 GiB VG UUID Dd5nRh-qzsj-z6rX-H1o1-JzMd-kXEI-7bWoEx |
...
Kodeblok |
---|
lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv |
Now, we can see 0 "Free PE :/ Size 0 / 0"
Kodeblok |
---|
root@beetle:/home/bnp# vgdisplay --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <462.87 GiB PE Size 4.00 MiB Total PE 118494 Alloc PE / Size 118494 / <462.87 GiB Free PE / Size 0 / 0 VG UUID Dd5nRh-qzsj-z6rX-H1o1-JzMd-kXEI-7bWoEx |
Ubuntu is installed and the complete SSD Disk usedis now utilized.
Docker install
Lets install docker.io:
Kodeblok |
---|
apt install docker.io |
Frigate NVR Install
Find information on Frigate here
Tip |
---|
First, I generally put all docker stuff in /opt opt - and I dont use docker-compose very much. Maybee one day... |
Creating the needed Directory and the config Creating the needed Directory and the config file:
Kodeblok |
---|
mkdir /opt/frigate vi /opt/frigate/config |
...
The config file can be huge and there are plenty of options, here is my current:
Kodeblok |
---|
mqtt: host: 10.0.0.183 cameras go2rtc: streams: frigate_front_door_cam_main: ffmpeg: inputs: - path"ffmpeg: rtsphttp://view:10.0.0.151/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=******&password=*****@10.0.0.151:554//h264Preview_01_sub*#video=copy#audio=copy#audio=opus" roles: - detect frigate_front_door_cam_sub: - path"ffmpeg: rtsphttp://view:**********@@1010.0.0.151:554//h264Preview_01_main roles: /flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=******&password=******" frigate_behind_house_cam_main: - record rtmp: enabled: False"ffmpeg:http://10.0.0.176/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=******&password=******#video=copy#audio=copy#audio=opus" detectfrigate_behind_house_cam_sub: width: 640 height: 480 fps: 5 objects: track: - person- "ffmpeg:http://10.0.0.176/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=******&password=******" frigate_carport_cam_main: snapshots: enabled: True timestamp: false- "ffmpeg:http://10.0.0.191/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=******&password=******#video=copy#audio=copy#audio=opus" bounding_box: Truefrigate_carport_cam_sub: retain: default: 2 record: enabled: True events- "ffmpeg:http://10.0.0.191/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=******&password=******" frigate_big_shed_cam_main: - retain: default: 10 "ffmpeg:http://10.0.0.108/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=******&password=******#video=copy#audio=copy#audio=opus" frigate_behindbig_houseshed_cam_sub: ffmpeg: inputs: - path"ffmpeg: rtsphttp:///view:10.0.0.108/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=******&password=******@@10.0.0.176:554//h264Preview_01_sub" cameras: frigate_front_door_cam: rolesffmpeg: - detectinputs: - path: rtsp://view:**********@@10127.0.0.1761:5548554//h264Preview_01_mainfrigate_front_door_cam_sub?video=copy roles:input_args: preset-rtsp-restream - recordroles: rtmp: enabled: False - detect: width: 640 - heightpath: 480 fps: 5rtsp://127.0.0.1:8554/frigate_front_door_cam_main?video=copy&audio=aac objects: track: input_args: preset-rtsp-restream - personroles: snapshots: enabled: True - record timestamprtmp: false bounding_box: Trueenabled: False retaindetect: width: 640 default: 2 recordheight: 480 enabled: Truefps: 5 objects: eventstrack: - retain:person snapshots: defaultenabled: 10True frigate_carport_cam: ffmpegtimestamp: false inputsbounding_box: True retain: - path: rtsp://view:**********@@10.0.0.191:554//h264Preview_01_subdefault: 2 record: rolesenabled: True events: - detectretain: - path: rtsp://view:**********@@10.0.0.191:554//h264Preview_01_maindefault: 10 frigate_behind_house_cam: ffmpeg: rolesinputs: - record rtmp: enabled: Falsepath: rtsp://127.0.0.1:8554/frigate_behind_house_cam_sub?video=copy detect: widthinput_args: 640preset-rtsp-restream height: 480 roles: fps: 5 objects: - track:detect - person path: rtsp://127.0.0.1:8554/frigate_behind_house_cam_main?video=copy&audio=aac input_args: preset-rtsp- carrestream snapshots: enabledroles: True timestamp: false - bounding_box: Truerecord rtmp: retainenabled: False detect: defaultwidth: 2640 recordheight: 480 enabledfps: True 5 objects: eventstrack: - retain:person snapshots: defaultenabled: 10 detectors:True coral: typetimestamp: edgetpufalse device: usb birdseye: bounding_box: True retain: default: 2 record: enabled: True modeevents: continuous |
Tip |
---|
In short, the file sets up three cams (Reolink) - using:
|
Reference to the configuration file is here.
And the database file /opt/frigate/frigate.yml
Kodeblok |
---|
codedatabase:
path: /opt/frigate/frigate.db |
Now we can start Frigate:
Kodeblok |
---|
docker run -d \
--name frigate \
--restart always \
--mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
--device /dev/bus/usb:/dev/bus/usb \
--shm-size=256m \
-v /opt/frigate/media:/media/frigate \
-v /opt/frigate/config.yml:/config/config.yml:ro \
-v /etc/localtime:/etc/localtime:ro \
-e FRIGATE_RTSP_PASSWORD='**********' \
-p 5000:5000 \
-p 1935:1935 \
ghcr.io/blakeblackshear/frigate:master-433bf69-tensorrt |
This should start Frigate and show it on http://10.0.0.164:5000:
If the interface is not up, troubleshoot the logs with:
Kodeblok |
---|
docker logs --tail 50 --follow --timestamps "frigate" |
Coral Stick on Linux
I had some problems getting the Coral stick to work (the Frigate docker image has all needed for it), but it did not show up as an Device on the MacBook:
retain:
default: 10
frigate_carport_cam:
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/frigate_carport_cam_sub?video=copy
input_args: preset-rtsp-restream
roles:
- detect
- path: rtsp://127.0.0.1:8554/frigate_carport_cam_main?video=copy&audio=aac
input_args: preset-rtsp-restream
roles:
- record
rtmp:
enabled: False
detect:
width: 640
height: 480
fps: 5
objects:
track:
- person
- car
snapshots:
enabled: True
timestamp: false
bounding_box: True
retain:
default: 2
record:
enabled: True
events:
retain:
default: 10
frigate_big_shed_cam:
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/frigate_big_shed_cam_sub?video=copy
input_args: preset-rtsp-restream
roles:
- detect
- path: rtsp://127.0.0.1:8554/frigate_big_shed_cam_main?video=copy&audio=aac
input_args: preset-rtsp-restream
roles:
- record
rtmp:
enabled: False
detect:
width: 640
height: 480
fps: 5
objects:
track:
- person
- car
snapshots:
enabled: True
timestamp: false
bounding_box: True
retain:
default: 2
record:
enabled: True
events:
retain:
default: 10
detectors:
coral:
type: edgetpu
device: usb
birdseye:
enabled: True
mode: continuous |
Tip |
---|
In short, the file sets up 4 cams - using:
|
Reference to the configuration file is here.
And the database file /opt/frigate/frigate.yml
Kodeblok |
---|
codedatabase:
path: /opt/frigate/frigate.db |
Now we can start Frigate:
Kodeblok |
---|
docker run -d \
--name frigate \
--restart always \
--mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
--device /dev/bus/usb:/dev/bus/usb \
--shm-size=256m \
-v /opt/frigate/media:/media/frigate \
-v /opt/frigate/config.yml:/config/config.yml:ro \
-v /etc/localtime:/etc/localtime:ro \
-e FRIGATE_RTSP_PASSWORD='**********' \
-p 5000:5000 \
-p 1935:1935 \
ghcr.io/blakeblackshear/frigate:stable |
This should start Frigate and show it on http://10.0.0.164:5000:
If the interface is not up, troubleshoot the logs with:
Kodeblok |
---|
docker logs --tail 50 --follow --timestamps "frigate" |
Heres a view on object detection:
And a snapshot with an object detection (the yellow box is the bounding_box in the config file):
Coral Stick on Linux
I had some problems getting the Coral stick to work (the Frigate docker image has all needed for it), but it did not show up as an Device on the MacBook:
Kodeblok |
---|
root@beetle:/home/bnp# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 05ac:1463 Apple, Inc. USB-C Digital AV Multiport Adapter
Bus 001 Device 002: ID 05ac:1017 Apple, Inc. USB2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 002: ID 05ac:1018 Apple, Inc. USB3.1 Hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 |
Kodeblok |
root@beetle:/home/bnp# lsusb Bus 002 Device 001: ID 1d6b:00030002 Linux Foundation 32.0 root hub Bus 001004 Device 003002: ID 05ac0bda:1463 Apple, Inc. USB-C Digital AV Multiport8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter Bus 001004 Device 002001: ID 05ac1d6b:10170003 Apple,Linux Inc.Foundation USB23.0 Hubroot hub Bus 001003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 002: ID 05ac:1018 Apple, Inc. USB3.1 Hub Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 002: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub |
Loking at the links for the 2 versions - USB and M2
Kodeblok |
---|
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install gasket-dkms libedgetpu1-std |
So it seems my stick is detected as a PCI Device..
Loking at the links for the 2 versions - USB and M2
Kodeblok |
---|
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install gasket-dkms libedgetpu1-std |
So it seems my stick is detected as a PCI Device. Theres some more info on what to use as docker parameter here:
Kodeblok |
---|
- /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
- /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
- /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware |
And now its visibleAnd now:
Kodeblok |
---|
root@beetle:/home/bnp# lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 05ac:1463 Apple, Inc. USB-C Digital AV Multiport Adapter Bus 001 Device 002: ID 05ac:1017 Apple, Inc. USB2.0 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 003: ID 1a6e:089a Global Unichip Corp. Bus 006 Device 002: ID 05ac:1018 Apple, Inc. USB3.1 Hub Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 002: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub |
...