Unconditional scaling 1920x1080 in ffmpeg cmdline #20372
-
Describe the problem you are havingFollowing the docs recommendations I prepared the input streams to have res 1920x1080 and f_rate 5fps for some sreams and 7fps for another ones. Scaling and fps changing were implemented by separate go2rtc/ffmpeg instance on standalone RPi. Values for fps were derived by integer division by 3 from 15 and by 2 from 14 source cameras fps. All this was done to reduce CPU load on Frigate RPi. Version0.16.1-e664cb2 Frigate config filemqtt:
enabled: true
host: raspberrypi
user: ha_mqtt
password: MqTt_pass
#go2rtc:
# streams: #
# Vyezd: rtsp://192.168.10.11:8554/8m_m
ffmpeg:
hwaccel_args: -hwaccel drm
cameras:
8m_m:
name: 8m_m
enabled: true
ffmpeg:
inputs:
- path: rtsp://rpig2r:8554/8m_m_264 # <----- The stream you want to use for detection
roles:
- detect
detect:
enabled: true # <---- disable detection until you have a working camera feed
width: 1920
height: 1080
fps: 5
zones:
car_num:
coordinates: 0.362,0.003,0.685,0.005,0.876,0.761,0.445,0.932
loitering_time: 0
motion:
threshold: 30
contour_area: 15
improve_contrast: true
v380_top:
enabled: true
ffmpeg:
inputs:
- path: rtsp://raspberrypi:8554/v380_m_264_top # <----- The stream you want to use for detection
roles:
- detect
detect:
enabled: false # <---- disable detection until you have a working camera feed
width: 1920
height: 1080
fps: 7
v380_btm:
enabled: true
ffmpeg:
inputs:
- path: rtsp://raspberrypi:8554/v380_m_264_btm # <----- The stream you want to use for detection
roles:
- detect
detect:
enabled: false # <---- disable detection until you have a working camera feed
width: 1920
height: 1080
fps: 7
detect:
enabled: true
detectors: # <---- add detectors
coral:
type: edgetpu
device: pci
version: 0.16-0Relevant Frigate log outputno any log outputRelevant go2rtc log outputno any outputFrigate statsNo response Operating systemDebian Install methodDocker Compose docker-compose file or Docker CLI commandname: nvr
services:
# go2rtc:
# container_name: go2rtc
# image: "alexxit/go2rtc"
# restart: unless-stopped # autorestart on fail or config change from WebUI
# network_mode: host # important for WebRTC, HomeKit, UDP cameras
# privileged: true # only for FFmpeg hardware transcoding
# environment:
# - TZ=Europe # timezone in logs
# volumes:
# - "./go2rtc:/config" # folder for go2rtc.yaml file (edit from WebUI)
frigate:
container_name: frigate
image: "ghcr.io/blakeblackshear/frigate:stable"
restart: unless-stopped
stop_grace_period: 30s
privileged: true # ?? for FFmpeg hardware transcoding
volumes:
- /etc/localtime:/etc/localtime:ro
- /opt/nvr/frigate/config:/config
- /opt/nvr/frigate/storage:/media/frigate
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 384000000
shm_size: 384000000
ports:
- "8971:8971"
#- "8554:8554" # RTSP feeds
devices:
# - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
- /dev/apex_0:/dev/apex_0Object DetectorCoral Screenshots of the Frigate UI's System metrics pagesNo response Any other information that may be helpfulRPi 5 8Gb |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 14 replies
-
|
Based on the configuration documentation, Frigate applies automatic scaling and frame rate adjustments when detect stream settings are specified (1). When you configure detect settings like this: detect:
width: 1920
height: 1080
fps: 5Frigate automatically adds scaling and frame rate conversion to ensure the detect stream matches these specifications (1). This is by design to optimize object detection performance. The documentation shows that detect configuration includes optional width, height, and fps settings that default to using native stream resolution when not specified (1). When you do specify these values, Frigate ensures the detect stream conforms to them through ffmpeg processing. The scaling operations you're seeing (
If you want to avoid this scaling overhead, you would need to ensure your input streams already match exactly the resolution and frame rate you want for detection, and potentially omit the detect width/height/fps settings to let Frigate use the native stream properties (1). However, the documentation recommends a detect resolution and frame rate of 5 fps for optimal performance (2). The scaling operations, while CPU-intensive, are typically necessary for proper object detection functionality. 📚 Sources: Have another question? Just tag @inkeep. |
Beta Was this translation helpful? Give feedback.
-
They are not CPU-heavy in this case as they match what is already provided by the camera. |
Beta Was this translation helpful? Give feedback.
-
|
@NickM-27 |
Beta Was this translation helpful? Give feedback.
-
|
compared to situation when any values wasn't set in config. |
Beta Was this translation helpful? Give feedback.
-
|
@NickM-27 And what to say about this (I did shots with values and then after removing them)? It's not the 7% but 3-4% for sure + this warning about "high usage..."
P.S. I've double checked these results.. |
Beta Was this translation helpful? Give feedback.
-
|
Ok. Agree with You. |
Beta Was this translation helpful? Give feedback.
-
|
Just a few words for completeness. |
Beta Was this translation helpful? Give feedback.
-
|
Now trying to tune LPR for my car. It's all about the default resolution. Seems for LPR it's need to be more than 1920x1080.. |
Beta Was this translation helpful? Give feedback.
Yes, and processing 7 frames is more work than processing 5. But you are mistaken that the -vf is the part using cpu.
The cpu is required to convert the frames to yuv420 format. Doing this on 7 frames instead of 5 is more work. I've already told you if you set it to 5 it will reduce cpu usage.
If you don't want to do this then that's your choice, but that is what is leading to higher cpu usage. I've already explained why it works the way it does, those options don't add to the cpu usage.