AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
6.97k stars 499 forks source link

How to configure go2rtc as a ONVIF _server_? #1036

Open theschles opened 7 months ago

theschles commented 7 months ago

Hi all,

Using go2rtc 1.8.5 as port 1984 on a docker instance running on a Raspberry Pi 3. go2rtc works great with RTSP and HTTP streaming to tablets and to Home Assistant clients on my LAN (single subnet).

I’m now trying to get the Roku IP Camera Viewer Basic version to display a camera feed on my TV. As it requires a MJPEG-encoded feed, I configured the settings in the Roku camera app as:

IP: <IP of Raspberry Pi>
Port: 1984
URL: /stream.html?src=my_camera_instance&mode=mjpeg

Doesn’t work.

I also tried just:

IP: <IP of Raspberry Pi>
Port: 1984
URL: /stream.html?src=my_camera_instance

Again, nada nada.

That’s when I learned about ONVIF. If I’m RTFM’ing correctly, if the go2rtc server instance advertised as a ONVIF server (or at least had the right port open), the camera feeds on my go2rtc would be discoverable by the Roku camera app.

Right now, however, when I tell the Roku camera app to scan my network for ONVIF instances, it doesn’t detect anything.

Help?

AlexxIT commented 7 months ago

Your URL doesn't have stream name in src param. So them doesn't work. go2rtc doesn't provide ONVIF auto-discovery feature. ONVIF server runs at same port as Web API.

theschles commented 7 months ago

Your URL doesn't have stream name in src param. So them doesn't work. go2rtc doesn't provide ONVIF auto-discovery feature. ONVIF server runs at same port as Web API.

Hi @AlexxIT -- apologies, because I didn't wrap the IP / Port / URL entries inside a code-block, the stuff I angle-bracketed didn't display.

Please re-review what I have above?

Thank you for your assistance!

AlexxIT commented 7 months ago

MJPEG will work for you only if source camera support it. Or if you setup transcoding via ffmpeg.

If your app support only MJPEG stream - html link won't work. It's only for browsers.

latel commented 2 weeks ago

It's sad to find lots of onvif camera viewers like scrypted or synology surveillance, I cannot provide the camera's name in the onvif address, They typically only support ip/port/username/password configuration, without path configuration.

image

synology surveillance told it's an invalid address

image

scrypted will become no-response when click add button, the coding looks also does not support this https://github.com/koush/scrypted/blob/17ecb56259c8f61bb7e6f3aa4de892b6fe179ce6/plugins/onvif/src/main.ts#L429

acortelyou commented 3 days ago

The ability to configure go2rtc for adoption in unifi protect's recently added onvif support would effectively open that platform.

{CA700787-F8DC-4534-BECE-841D601913CE}

Creating the interfaces for other IPs is probably a bit much, but assuming they exist on the host: would adding the ability to configure additional instances of the existing onvif server to listen on a specific interface be reasonable?

Initial suggestion for configuration options to start a discussion:

onvif:
- listen: 192.168.1.5:8000
  advertise: true
  name: Channel 5
  model: go2rtc
  highStream: channel5
  lowStream: channel5lq
- listen: 192.168.1.6:8000
  advertise: false
  name: Channel 6
  model: go2rtc
  highStream: channel6
  lowStream: channel6lq

There is a mostly working reference implementation here: https://github.com/p10tyr/rtsp-to-onvif/

Advertising go2rtc's rtsp's streams with both high and low quality works great but snapshots are currently glitchy (ECONNRESET for frame.jpeg, intermittent for frame.mp4, unclear to me it's the tcp-proxy that project is using or some other interaction or just a bug on unifi's side).

Thanks!

AlexxIT commented 3 days ago
acortelyou commented 3 days ago
  • Usually ONVIF expected only host and port, not URL

Right, I think this issue is about the potential need for additional config/doc around how go2rtc implements the existing onvif server.

  • Multiple ONVIF severs in plans. It's a big task

Wonderful, glad to hear multiple onvif output is in planning.

  • You can now run multiple instances of go2rtc. And get multiple ONVIF servers in this way

Agreed, until multiple onvif output is implemented multiple instances of go2rtc should be workable.

I'll continue the discussion around getting an go2rtc instance into Unifi Protect as a camera over in #613 after wiresharking the adoption to compare the working rtsp-to-onvif and non-working go2rtc flows.

Thanks!