Skip to content

WebRTC live view not working, but HLS does #412

@INeatFreak

Description

@INeatFreak

LightNVR v0.34.4 is running in docker container with this compose:

  lightnvr:
    container_name: lightnvr
    image: ghcr.io/opensensor/lightnvr:latest
    restart: unless-stopped
    networks:
      - caddy        # used as reverse proxy
    volumes:
      - /opt/lightnvr/config:/etc/lightnvr
      - /opt/lightnvr/data:/var/lib/lightnvr/data
    ports:
      - "8080:8080"          # Web UI (HTTP)
      - "8554:8554"          # RTSP Stream
      - "8555:8555"          # WebRTC (TCP)
      - "8555:8555/udp"      # WebRTC (UDP)
      - "1984:1984"          # go2rtc API
    environment:
      - LIGHTNVR_ONVIF_NETWORK=192.168.2.0/24
      - GO2RTC_CONFIG_PERSIST=true

On "Streams" tab the preview thumbnail of camera view does update every time I reload the page (image is intentionally blurred)

Image

And on "Live View" tab, HLS view also works, there's live view streaming from camera, although a bit laggy. And ONVIF events also do trigger to record videos on movement.

Image

But the WebRTC just keeps saying "Stream is starting..." then either it says "WebRTC connection lost. Please retry." or this error on screenshot pops up. It's not a firewall issue since I have tried with it disabled and didn't fix it. Tried deleting streams and re-adding, changing External IP on settings to both 192.168.2.1 and the local static ip of my host machine but none of it worked. Also tried other cameras and different browsers but still no chance.

Image

Cameras are Reolink that are on 192.168.2.0 subnet. Here's my stream settings, I've added camera ip + url and added ONVIF login credentials.

Image

Other than this I've only changed recording mode to detection based on ONVIF events, haven't messed with any other settings. Do I need to setup extra things for WebRTC to work? like go2rtc overrides? I've checked the go2rtc.yaml file and url is being generated as it should

# go2rtc configuration generated by NVR software

api:
  listen: :1984
  base_path: /go2rtc
  origin: '*'

rtsp:
  listen: ":8554"

webrtc:
  listen: ":8555"
  ice_servers:
    - urls:
      - "stun:stun.l.google.com:19302"
      - "stun:stun1.l.google.com:19302"
      - "stun:stun2.l.google.com:19302"
      - "stun:stun3.l.google.com:19302"
      - "stun:stun4.l.google.com:19302"
  candidates:
    - "*:8555"
    - "stun:stun.l.google.com:19302"

ffmpeg:
  h264: "-codec:v libx264 -g:v 30 -preset:v superfast"
  h265: "-codec:v libx265 -g:v 30 -preset:v superfast"

streams:
  # Streams will be added dynamically via API
  RL1:
    - rtsp://viewer:<redacted-password>@192.168.2.101:554/Preview_01_main#transport=tcp#timeout=30
preload:
  RL1: audio=&video=

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions