Skip to content
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Ultimate camera streaming application with support RTSP, WebRTC, HomeKit, FFmpeg
* [Module: MP4](#module-mp4)
* [Module: HLS](#module-hls)
* [Module: MJPEG](#module-mjpeg)
* [Module: ONVIF](#module-onvif)
* [Module: Log](#module-log)
* [Security](#security)
* [Codecs filters](#codecs-filters)
Expand Down Expand Up @@ -1208,6 +1209,46 @@ API examples:

[![](https://img.youtube.com/vi/sHj_3h_sX7M/mqdefault.jpg)](https://www.youtube.com/watch?v=sHj_3h_sX7M)

### Module: ONVIF

This module provides an **ONVIF server** that allows go2rtc to act as an ONVIF-compatible device, making it easier to integrate cameras with ONVIF-supported software like Dahua NVRs or Home Assistant.

With ONVIF support, go2rtc can:
- Expose configured streams as ONVIF profiles.
- Provide additional ONVIF functionalities like `GetOSDs` to show camera name in Dahua NVR.
- Maintain a **consistent camera order** to prevent issues with NVRs that rely on `GetProfilesResponse` for identification.

**Example Configuration**

```yaml
onvif:
- name: Camera 1
main_stream: camera1
sub_stream: camera1_lq
Copy link
Contributor

@felipecrs felipecrs Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should think on how this config will look like in the future. How about:

onvif:
  - name: Camera 1
    streams:
      - camera1
      - camera1_lq

The first stream would always be mainstream, while the second would be substream if present.

By the way some cameras have additional streams, how are they usually exposed in this case? Maybe we should support it too.

This approach is better because it doesn't require to document third_stream, fourth_stream, options. Also, it's less things to type.

As per resolution, maybe this?

onvif:
  - name: Camera 1
    streams:
      - camera1#res=1920x1080
      - camera1_lq#res=1270x720

Very go2rtc-style. :)

Copy link
Contributor

@felipecrs felipecrs Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing is, you are adding onvif at the top as an array of cameras. But what if in the future we may want to other introduce onvif global configurations?

To protect against this, I think you should make it a nested option within the top onvif like this:

onvif:
  cameras: # or maybe "profiles"?
    - name: Camera 1
      # ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for feedback.
I changed OnvifCameras to OnvifProfiles and added function to parse stream arguments (res, codec).

New config:

onvif:
  profiles:
    - name: Camera 1
      streams:
        - camera1#res=1920x1080
        - camera1_lq#res=1270x720#codec=H265
    - name: Camera 2
      streams:
        - camera2#res=1920x1080#codec=H265
        - camera2_lq#res=1270x720

By default:

  • res=1920x1080
  • codec=H264

- name: Camera 2
main_stream: camera2
sub_stream: camera2_lq

streams:
camera1:
- rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=0&unicast=true
camera1_lq:
- ffmpeg:camera1#video=h264#height=360
camera2:
- rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=0&unicast=true
camera2_lq:
- ffmpeg:camera2#video=h264#height=360
```

**Example Dahua NVR configuration:**
- **Channel**: <camera channel on NVR>
- **Manufacturer**: ONVIF
- **IP Address**: <go2rtc IP>
- **RTSP Port**: Self-adaptive
- **HTTP Port**: <go2rtc http api port, eg. 1984>
- **Username / Password**: Currently auth is not supported by go2rtc
- **Remote CH No.**: <camera index from onvif array, counting from 1>

### Module: Log

You can set different log levels for different modules.
Expand Down