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.72k stars 484 forks source link

RTSP Streaming: problems with Apple devices #927

Closed francescobianca closed 5 months ago

francescobianca commented 9 months ago

Hi, I am using this library with nginx in front for streaming rtsp. Tested without problems with linux and windows while it gives us problems with Apple devices (any browser). This is my go2rtc.yaml

streams:
  stream_key: rtsp://{USERNAME}:{PASSWORD}@{SERVER_IP}:{SERVER_PORT}/cam/realmonitor?channel=1&subtype=2#timeout=30

log:
  level: info  # default level
  rtsp: debug
  streams: debug
  webrtc: debug

My docker compose:

version: '3.7'

services:

  nginx:
    image: my_registry/openresty-nginx-jwt:0.1.0
    ports:
      - "443:443"
    volumes:
      - ./nginx/conf/nginx.conf:/nginx.conf
      - ./nginx/conf/bearer.lua:/bearer.lua
      - ./nginx/certs:/conf/certs:ro
    environment:
      JWT_SECRET: ${JWT_SECRET}

  go2rtc:
    image: alexxit/go2rtc
    volumes:
      - ./go2rtc/go2rtc.yaml:/config/go2rtc.yaml

The nginx only does the proxy pass on the 1984 internal go2rtc. With the mac we are only able to view MSE. Instead, the link we would like to reproduce is as follows:

https://{addresss}/webrtc.html?src=stream_key&media=video

NB: it works correctly on other operating systems while giving errors only on Apple. Has anyone ever had such problems?

AlexxIT commented 9 months ago

I never tested it yet, but I have the theory that Safari didn't support WebRTC over TCP. You have not open any ports for go2rtc container, so UDP connection can't be made

francescobianca commented 9 months ago

can you share me an example? I am using a dahua camera and the js code present in this repo (www directory). The problem on apple is on all browsers (not just safari)

AlexxIT commented 9 months ago

Apple has only one browser on iPhones and iPads. Notebooks are exception.

Docker container example on Docker hub.

francescobianca commented 9 months ago

MSE appears to be compatible with macOS. I will use that if the system is Apple. If anyone knows more about this issue please respond on this issue

AlexxIT commented 9 months ago

I'll check go2rtc with closed ports with my Apple devices when I have time. But go2rtc without network host is not recommended usage.

francescobianca commented 9 months ago

Okay thanks, it's just that I want to control the access behind a nginx with TCP. Anyway, good job! Apart from this problem with Apple it works perfectly

AlexxIT commented 9 months ago

WebRTC is p2p connection. Nginx not involved to it any way. TCP or UDP, not matter

AlexxIT commented 5 months ago

Can't confirm this problem. All works fine on Apple devices. Even via closed docker ports (which is not recommended, but it works).