frigate icon indicating copy to clipboard operation
frigate copied to clipboard

[Config Support]: Adjust aspect ratio in substream

Open avvalex opened this issue 2 years ago • 5 comments

Describe the problem you are having

Hi, i'm trying to setup my first cam in Frigate. I'm using 4mp stream for RTMP and 640x480 sub stream for detection. I've tried somr ffmpeg arguments that should correct sub stream wrong aspect ratio (from 4:3 to 16:9) but no one of them seems to change anything. If i'll be able to correct aspect ratio i would use sub stream also for RTMP (leaving 4MP only for recording).

I've tried:

output_args: detect: -aspect 854:480 -c copy -f flv

output_args: detect: -vf scale=854:480 -f rawvideo -pix_fmt yuv420p

The image remains always the same on Frigate (4:3 instead of 16:9). Is there a way to stretch the image to 16:9?

Version

0.10.1-83481af

Frigate config file

mqtt:
  host: xxx.xxx.xxx.xxx
  port: xxxxx
  topic_prefix: frigate
  client_id: frigate
  user: xxxxxxxxxxxx
  password: xxxxxxxxxxxx
  stats_interval: 120

detectors:
  cpu:
    type: cpu
    num_threads: 2
    
cameras:
  xxxxxxxxx:
    ffmpeg:
      inputs:
        - path: rtsp://xxxxxxx:xxxxxxxxxxxxxx@xxxxxxxxxxxxxxxx:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - record
            - rtmp
        - path: rtsp://xxxxxxx:xxxxxxxxxxxxxx@xxxxxxxxxxxxxxxx:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
    detect:
      width: 640
      height: 480
      fps: 5
    objects:
      track:
        - person
      filters:
        person:
          threshold: 0.6
    rtmp:
      enabled: true
    record:
      enabled: true
      expire_interval: 60
      retain:
        days: 10
        mode: all
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      retain:
        default: 3

Relevant log output

.

Frigate stats

No response

Operating system

Debian

Install method

Docker CLI

Coral version

CPU (no coral)

Any other information that may be helpful

No response

avvalex avatar Dec 10 '22 10:12 avvalex

Just set the width in the detect config to 854 and frigate will have ffmpeg resize it. You can remove your custom output args.

blakeblackshear avatar Dec 10 '22 12:12 blakeblackshear

That won't fix the rtmp restream though.

blakeblackshear avatar Dec 10 '22 12:12 blakeblackshear

Ooops, so simple.... :-P Just one more precisation: setting width differently from original frame resolution (854 instead of 640) can cause some detection problems in some ways?

avvalex avatar Dec 10 '22 14:12 avvalex

If setting the resolution to 854 sets the stream so that it is no longer warped, it should improve detection.

blakeblackshear avatar Dec 10 '22 16:12 blakeblackshear

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 10 '23 00:01 github-actions[bot]