Frigate - Choppy stream in HA via Cloudflare tunnel (outside from home)

Hi there. First post / Frigate setup here

I am currently running Frigate and using the Advanced Camera Card in Home Assistant, but the remote streaming performance is basically unusable.

For some context, Frigate is running on Proxmox (Optiplex with 11500T), and the camera in is a Reolink PoE Doorbell. To access my home network remotely, I bought a domain and set up a standard Cloudflare tunnel.

The setup works great at home. When I am connected to my home network, the live camera streams load instantly and plays at full framerate (within both the Frigate UI and my HA dashboard). But the moment I disconnect from home and try to access it from the outside (using mobile data through my Cloudflare tunnel), the stream gets incredibly laggy. It instantly drops to roughly 1 FPS and looks like a slow slideshow, or worse. It's choppy and 5ish seconds delayed.

I roughly understand Cloudflare tunnels can sometimes interfere with direct WebRTC connections, so I suspect my setup is failing to negotiate WebRTC and is silently falling back to a slower protocol like MSE or MP4? I am just not entirely sure what I need to change in my configuration to fix the remote pipeline.

Any help would be greatly appreciated!

(my current config)

Frigate:

mqtt:
  enabled: true
  host: [MQTT_IP]
  user: admin
  password: [MQTT_PASSWORD]

auth:
  enabled: false

go2rtc:
  webrtc:
    candidates:
      - [FRIGATE_LOCAL_IP]:8555
      - stun:8555
  streams:
    doorbell:
      - "ffmpeg:http://[CAMERA_IP]/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=[CAMERA_PASSWORD]#video=copy#audio=copy#audio=opus"
    doorbell_sub:
      - "ffmpeg:http://[CAMERA_IP]/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=[CAMERA_PASSWORD]#video=copy#audio=opus"

ffmpeg:
  hwaccel_args: preset-vaapi

detectors:
  detector01:
    type: openvino
    device: GPU 

model:
  width: 300
  height: 300
  input_tensor: nhwc
  input_pixel_format: bgr
  path: /openvino-model/ssdlite_mobilenet_v2.xml
  labelmap_path: /openvino-model/coco_91cl_bkgr.txt

cameras:
  doorbell:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/doorbell_sub
          input_args: preset-rtsp-restream 
          roles:
            - detect
        - path: rtsp://127.0.0.1:8554/doorbell
          input_args: preset-rtsp-restream 
          roles:
            - record
    detect:
      enabled: true
      width: 640
      height: 480
      fps: 5
    record:
      enabled: true
      continuous:
        days: 3 
      alerts:
        retain:
          days: 90    
          mode: motion 
      detections:
        retain:
          days: 90 
          mode: motion 
    snapshots:
      enabled: true
      retain:
        default: 90   
    zones:
      front_porch:
        coordinates: 
          0.819,0.997,0.617,0.611,0.507,0.61,0.213,0.571,0.197,0.583,0.153,0.574,0.145,0.51,0.002,0.587,0,0.999
        loitering_time: 0
        friendly_name: Front Porch
        inertia: 3
    motion:
      mask: 
        0.002,0.587,0.145,0.51,0.153,0.574,0.197,0.583,0.22,0.572,0.507,0.61,0.617,0.611,0.819,0.997,0,0.999
    objects:
      mask: 
        0.002,0.587,0.145,0.51,0.153,0.574,0.197,0.583,0.213,0.571,0.507,0.61,0.617,0.611,0.819,0.997,0.999,0.998,1,0,0,0

version: 0.17-0

Advanced Camera Card:

type: custom:advanced-camera-card
view:
  default: live
cameras:
  - camera_entity: camera.doorbell
    live_provider: go2rtc
    go2rtc:
      stream: doorbell
      modes:
        - webrtc
        - mse
        - mp4
live:
  preload: true
  lazy_load: false
  auto_play:
    - selected
    - visible
menu:
  style: outside
  buttons:
    cameras:
      enabled: false
    media_player:
      enabled: false
    timeline:
      enabled: true
    image:
      enabled: false

It could also be the internet connection.
What upload and download bandwidth do you have?

Also, I'm fairly sure video streaming violates Cloudflare tunnels TOS

Frigate Documentation pages might help and
blakeblackshear/frigate · Discussions · GitHub is the official Frigate support hub and is another good place to get help with Frigate if you don't get an answer here.

I believe that’s only true if you’re caching the content. If you create a rule to bypass caching on your HA URL then you should be fine.