Skip to content

Instantly share code, notes, and snippets.

@lnxd
Created August 7, 2025 06:57
Show Gist options
  • Select an option

  • Save lnxd/7060f5d768f44f29cf8a9c673a3ce7b2 to your computer and use it in GitHub Desktop.

Select an option

Save lnxd/7060f5d768f44f29cf8a9c673a3ce7b2 to your computer and use it in GitHub Desktop.

Virtual Cameras in Frigate

Create extra views (sky-only, cropped, perspective-corrected, etc.) from one physical camera. Handy, but very resource intensive.


Contents


Implementation

1 – Go2RTC stream

go2rtc:
  streams:
    # Physical camera
    balcony:
      - rtsp://user:pass@camera_ip/stream1

    # Virtual camera with filters
    balcony_sky:
      - ffmpeg:rtsp://user:pass@camera_ip/stream1#video=h264#raw=-vf \
        perspective=x0=80:y0=400:x1=1342:y1=104:x2=360:y2=1340:x3=1554:y3=1330,scale=1280:720#hardware

2 – Camera block

cameras:
  balcony_sky:
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-aac
      inputs:
        - path: rtsp://127.0.0.1:8554/balcony_sky
          roles: [record, detect]
    detect:
      width: 848
      height: 480
      fps: 5
    snapshots:
      enabled: true
      timestamp: true
      bounding_box: true
      quality: 95
    record:
      enabled: true
      retain:
        days: 30
        mode: motion
    motion:
      mask: [coords]
      threshold: 30
      contour_area: 10
      improve_contrast: true
    zones:
      Park:
        coordinates: [coords]
        loitering_time: 0
        objects: person
    objects:
      mask: [coords]

Key FFmpeg filters

Filter Purpose
perspective=… Rectifies angled shots
scale=1280:720 Down-scales to ease downstream load
#hardware Uses GPU/ASIC if available

Performance Review

Method

  1. 30-second CPU sample, virtual cam off
  2. 30-second CPU sample, virtual cam on
  3. docker stats --no-stream every second
  4. Average the samples, extrapolate to 24 h

Environment

Item Value
Host kernel Linux 6.8.12-13-pve
Frigate 0.15.0-beta2
Camera feed 1080 p RTSP (persp. + scale)

Results

State Avg CPU % CPU-s / day Samples
Virtual cam OFF 84.7 73 147 30
Virtual cam ON 266.2 230 016 30
Delta +181.6 % +156 869 30

Take-aways

  • Roughly CPU for one virtual cam.
  • Adds ~44 CPU-hours per day.
  • Filters (perspective + scale) are the main culprits.
  • Expect similar overhead for each extra virtual camera.

Recommendations

Use a virtual camera when:

  • Hardware acceleration is available.
  • A corrected or specialty view is important.
  • Different areas need different detection settings.

Don't use one when:

  • The host is already CPU-bound or has thermal issues.
  • A simple crop via zones is enough.

Alternative

Detection zones

zones:
  Sky_Area:
    coordinates: [coords]
    objects: []
  Ground_Area:
    coordinates: [coords]
    objects: [person, car]

Conclusion

Virtual cameras work reliably, but are extremely resource intensive. In my case, the cost of using the feature for over 6 months has exceeded the cost of a second camera.


Tested on Frigate 0.15.0-beta2. Results will vary with different filters, hardware, and acceleration support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment