TawfikDaim / home_automation

home automation user stories
0 stars 0 forks source link

docker-compose for frigate #66

Open TawfikDaim opened 3 months ago

TawfikDaim commented 3 months ago

docker-compose file:

version: "3.1" services: frigate: container_name: frigate-dockercompose image: ghcr.io/blakeblackshear/frigate:stable shm_size: "484mb" # update for your cameras based on calculation above restart: always volumes:

Mounting a remote volume:

  #sudo apt install sshfs
#sudo mkdir /mnt/
#sudo sshfs -o allow_other Tawfik@192.168.1.100:/share/Dyar153/recordings/ /home/tawfik/Videos/
# can use this on a remote server or on same server at a specific folder
  - /home/tawfik/docker/frigate/config/frigate.yaml:/config/config.yaml
  - /home/tawfik/docker/frigate/:/media/frigate

- /home/tawfik/Videos/:/media/frigate # secind line will be ignored

# if using as a local server then will be
# using same logic can get the config file from a emote server or on same server at a specific folder
#- /home/tawfik/frigate/frigate.yaml:/config/config.yaml
#- /home/tawfik/frigate/media:/media/frigate
#- //192.168.1.100/dyar153/recordings:/media/frigate
ports:
  - 5000:5000
  - 1935:1935
environment:
  TZ: Africa/Cairo
  FRIGATE_RTSP_PASSWORD: Newipad1
  Path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TawfikDaim commented 3 months ago

tawfik@tawfik-IdeaPad-3-15ITL6:~/Docker/frigate/config$ cat frigate.yaml

mqtt:

host: 10.195.1.254

host: 192.168.1.26

port: 1883

user: tawfik password: Newipad1! host: 192.168.1.53

cameras: maindoor: ffmpeg: inputs:

motion:

Optional: The threshold passed to cv2.threshold to determine if a pixel is different enough to be counted as motion. (default: shown below)

Increasing this value will make motion detection less sensitive and decreasing it will make motion detection more sensitive.

The value should be between 1 and 255.

threshold: 25

Optional: Minimum size in pixels in the resized motion image that counts as motion (default: 30)

Increasing this value will prevent smaller areas of motion from being detected. Decreasing will

make motion detection more sensitive to smaller moving objects.

As a rule of thumb:

- 15 - high sensitivity

- 30 - medium sensitivity

- 50 - low sensitivity

contour_area: 30

Optional: Alpha value passed to cv2.accumulateWeighted when averaging the motion delta across multiple frames (default: shown below)

Higher values mean the current frame impacts the delta a lot, and a single raindrop may register as motion.

Too low and a fast moving person wont be detected as motion.

delta_alpha: 0.2

Optional: Alpha value passed to cv2.accumulateWeighted when averaging frames to determine the background (default: shown below)

Higher values mean the current frame impacts the average a lot, and a new object will be averaged into the background faster.

Low values will cause things like moving shadows to be detected as motion for longer.

https://www.geeksforgeeks.org/background-subtraction-in-an-image-using-concept-of-running-average/

frame_alpha: 0.2

Optional: Height of the resized motion frame (default: 50)

This operates as an efficient blur alternative. Higher values will result in more granular motion detection at the expense

of higher CPU usage. Lower values result in less CPU, but small changes may not register as motion.

frame_height: 50

Optional: improve contrast (default: shown below)

Enables dynamic contrast improvement. This should help improve night detections at the cost of making motion detection more sensitive

for daytime.

improve_contrast: False

detect:

Width of the frame for the input with the detect role

width: 3072

Height of the frame for the input with the detect role

height: 1728

Desired fps for your camera for the input with the detect role

fps: 5

Number of frames without a detection before frigate considers an object to be gone.

max_disappeared: 25

objects:

Optional: list of objects to track from labelmap.txt

track:

maindoor:

ffmpeg:

inputs:

- path: rtsp://admin:Newipad1@192.168.1.103:554/Steaming/Channels/101

#      roles:
 #       - rtmp
  #      - detect

basket:

ffmpeg:

inputs:

#    - path: rtsp://admin:Newipad1@192.168.1.101:554/Steaming/Channels/101
 #     roles:
  #      - rtmp
   #     - detect

jaccuzi:

ffmpeg:

inputs:

#    - path: rtsp://admin:Newipad1@192.168.1.106:554/Steaming/Channels/101
 #     roles:
  #      - rtmp
   #     - detect

birdseye:

Optional: Enable birdseye view (default: shown below)

enabled: True

Optional: Width of the output resolution (default: shown below)

width: 1280

Optional: Height of the output resolution (default: shown below)

height: 720

Optional: Encoding quality of the mpeg1 feed (default: shown below)

1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.

quality: 8

Optional: Mode of the view. Available options are: objects, motion, and continuous

objects - cameras are included if they have had a tracked object within the last 30 seconds

motion - cameras are included if motion was detected in the last 30 seconds

continuous - all cameras are included always

mode: objects

record: sync_recordings: False enabled: True

Number of minutes to wait between cleanup runs - one week

expire_interval: 10080

Number of days to retain recordings regardless of events

retain: days: 2 mode: motion

snapshots:

Enable writing jpg snapshot to /media/frigate/clips

enabled: True

Print a timestamp on the snapshots

timestamp: True

Draw bounding box on the snapshots

bounding_box: True retain:

Retention days

default: 10

#

ffmpeg:

hwaccel_args: preset-intel-qsv-h264

TawfikDaim commented 1 month ago

8 May 2024: New config working much better, especially with theses camera settings

Docker compose - please note shm_size memory version: "3.1" services: frigate: container_name: frigate image: ghcr.io/blakeblackshear/frigate:stable shm_size: "22484mb" # update for your cameras based on calculation above restart: always volumes:

Mounting a remote volume:

  #sudo apt install sshfs
#sudo mkdir /mnt/
#sudo sshfs -o allow_other Tawfik@192.168.1.100:/share/Dyar153/recordings/ /home/tawfik/Videos/
# can use this on a remote server or on same server at a specific folder
  - /home/tawfik/automation/frigate/frigate.yaml:/config/config.yaml
  - /home/tawfik/automation/frigate/:/media/frigate

- /home/tawfik/Videos/:/media/frigate # secind line will be ignored

# if using as a local server then will be
# using same logic can get the config file from a emote server or on same server at a specific folder
#- /home/tawfik/frigate/frigate.yaml:/config/config.yaml
#- /home/tawfik/frigate/media:/media/frigate
#- //192.168.1.100/dyar153/recordings:/media/frigate
ports:
  - 5000:5000
  - 1935:1935
environment:
  TZ: Africa/Cairo
  FRIGATE_RTSP_PASSWORD: Newipad1
  Path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

version: "3.7"

services:

mqtt5: image: eclipse-mosquitto container_name: mqtt5 ports:

volumes for mapping data,config and log

volumes:

config:

data:

log:

networks:

default:

name: mqtt5-network

version: "3.1"

services:

z2mqtt: container_name: z2mqtt image: koenkk/zigbee2mqtt restart: always

priviliged: true

devices:
  - /dev/ttyACM0:/dev/ttyACM0
volumes:
#Mounting a remote volume:
 #sudo apt install sshfs
 #sudo mkdir /mnt/<folder name>
 #sudo sshfs -o allow_other Tawfik@192.168.1.100:/share/Dyar153/recordings/ /home/tawfik/Videos/
 # can use this on a remote server or on same server at a specific folder
  - /home/tawfik/automation/z2mqtt:/app/data
  - /run/udev:/run/udev:ro
 # if using as a local server then will be
 # using same logic can get the config file from a emote server or on same server at a specific folder
 #- /home/tawfik/frigate/frigate.yaml:/config/config.yaml
 #- /home/tawfik/frigate/media:/media/frigate
 #- //192.168.1.100/dyar153/recordings:/media/frigate
ports:
  - 8080:8080
environment:
  TZ: Africa/Cairo
 #FRIGATE_RTSP_PASSWORD: Newipad1!
 #Path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

version: '3'

services:

homeassistant: container_name: homeassistant image: "ghcr.io/home-assistant/home-assistant:stable" volumes:

version: "2.1"

services:

duckdns:

image: lscr.io/linuxserver/duckdns:latest

container_name: duckdns

environment:

- PUID=1000 #optional

- PGID=1000 #optional

- TZ=Africa/Cairo

- SUBDOMAINS

- TOKEN=4ebd937a-2ac0-46ab-a28b-2a8633ec8529

- LOG_FILE=true #optional

volumes:

- /home/tawfik/automation/duckdns/appdata/config:/config #optional

restart: unless-stopped

---

version: "3.7"

services:

tailscale-nginx:

image: tailscale/tailscale:latest

hostname: tawfik-IdeaPad-3-15ITL6

container_name: tailscale-nginx

environment:

- TS_AUTHKEY=tskey-auth-kor7U8Fnfb11CNTRL-GiU1BswqXVFcer22DiL1WF4JjkcdQS6p2

- TS_EXTRA_ARGS=--advertise-tags=tag:container

- TS_STATE_DIR=/var/lib/tailscale

- TS_USERSPACE=false

volumes:

- /home/tawfik/automation/tailscale-nginx/state:/var/lib/tailscale

- /dev/net/tun:/dev/net/tun

cap_add:

- net_admin

- sys_module

restart: unless-stopped

nginx:

image: nginx

depends_on:

- tailscale-nginx

network_mode: service:tailscale-nginx

services:

swag:

image: lscr.io/linuxserver/swag:latest

container_name: swag

cap_add:

- NET_ADMIN

environment:

- PUID=1000

- PGID=1000

- TZ=Africa/Cairo

- URL=dyararco.duckdns.org

- VALIDATION=http

- SUBDOMAINS=www, #optional

- CERTPROVIDER= #optional

- DNSPLUGIN=cloudflare #optional

- PROPAGATION= #optional

- EMAIL= #optional

- ONLY_SUBDOMAINS=false #optional

- EXTRA_DOMAINS= #optional

- STAGING=false #optional

volumes:

- /home/tawfik/automation/swag/config:/config

ports:

- 443:443

- 80:80 #optional

restart: unless-stopped

letsencrypt:

container_name: letsencrypt-nginx

image: linuxserver/letsencrypt

restart: unless-stopped

volumes:

- /etc/localtime:/etc/localtime:ro

- /home/tawfik/automation/nginx:/config

environment:

PGID: 1000

PUID: 1000

EMAIL: tawfikabdeldaim@gmail.com

URL: dyararco.duckdns.org

SUBDOMAINS: a153

VALIDATION: http

TZ: Africa/Cairo

ports:

- "80:80"

- "433:433"

Camera setting

Image

Image

Image

Frigate config mqtt: host: 10.195.1.51

host: 192.168.1.26

port: 1883

user: tawfik password: Newipad1!

host: 192.168.1.53

cameras: basket: ffmpeg: inputs:

detect:

Width of the frame for the input with the detect role

width: 3072

Height of the frame for the input with the detect role

height: 1728

Desired fps for your camera for the input with the detect role

fps: 5

Number of frames without a detection before frigate considers an object to be gone.

max_disappeared: 25

objects:

Optional: list of objects to track from labelmap.txt

track:

maindoor:

ffmpeg:

inputs:

- path: rtsp://admin:Newipad1@192.168.1.103:554/Steaming/Channels/101

#      roles:
 #       - rtmp
  #      - detect

basket:

ffmpeg:

inputs:

#    - path: rtsp://admin:Newipad1@192.168.1.101:554/Steaming/Channels/101
 #     roles:
  #      - rtmp
   #     - detect

jaccuzi:

ffmpeg:

inputs:

#    - path: rtsp://admin:Newipad1@192.168.1.106:554/Steaming/Channels/101
 #     roles:
  #      - rtmp
   #     - detect

birdseye:

Optional: Enable birdseye view (default: shown below)

enabled: true

Optional: Width of the output resolution (default: shown below)

width: 1280

Optional: Height of the output resolution (default: shown below)

height: 720

Optional: Encoding quality of the mpeg1 feed (default: shown below)

1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.

quality: 21

Optional: Mode of the view. Available options are: objects, motion, and continuous

objects - cameras are included if they have had a tracked object within the last 30 seconds

motion - cameras are included if motion was detected in the last 30 seconds

continuous - all cameras are included always

mode: objects

record: sync_recordings: false enabled: true

Number of minutes to wait between cleanup runs - one week

expire_interval: 10080

Number of days to retain recordings regardless of events

retain: days: 2 mode: motion

snapshots:

Enable writing jpg snapshot to /media/frigate/clips

enabled: true

Print a timestamp on the snapshots

timestamp: true

Draw bounding box on the snapshots

bounding_box: true retain:

Retention days

default: 10

#

ffmpeg:

hwaccel_args: preset-intel-qsv-h264

TawfikDaim commented 1 month ago

make sure to disable "Enable Motion Detection" on all cameras