deepch / RTSPtoWeb

RTSP Stream to WebBrowser
MIT License
1.19k stars 286 forks source link

No audio in WebRTC #225

Open i8beef opened 1 year ago

i8beef commented 1 year ago

Been playing with this for a few hours, and I'm stuck. I am passing my RTSP stream through rtsp-simple-server to convert the audio stream to pcm with the ffmpeg option -acodec pcm_mulaw. Confirmed in VLC that it thinks its PCM MU-LAW (mlaw) (sample rate 8000 Hz, bits per sample 16). But RTSPtoWeb WebRTC streams still don't appear to have any audio tracks in them.

My config for each stream channel has "audio": true in them, and I even tried setting it as a default in the server settings, and no dice.

Ideas?

JeDiE99 commented 1 year ago

logs when try play webrtc ? What full ffmpeg comand do you use in rtsp-simple-server ?

i8beef commented 1 year ago

Full ffmpeg command: ffmpeg -rtsp_transport tcp -i rtsp://192.168.1.90:554/cam/realmonitor?channel=1\&subtype=2 -acodec pcm_mulaw -vcodec copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH

Which logs do you want? The rtsp-to-web logs, level debug, and with debug true give me this:

INFO[2022-09-23T16:57:45Z] Server receive signalterminated func=main module=main INFO[2022-09-23T16:57:45Z] Stream exit by signal or not client call=StreamServerRunStream channel=0 func=StreamServerRunStreamDo module=core stream=frontdoor INFO[2022-09-23T16:57:45Z] Stream exit by signal or not client call=StreamServerRunStream channel=0 func=StreamServerRunStreamDo module=core stream=driveway INFO[2022-09-23T16:57:47Z] Server stop working by signal func=main module=main INFO[2022-09-23T16:57:47Z] Server CORE start func=main module=main INFO[2022-09-23T16:57:47Z] Server HTTP start call=Start func=RTSPServer module=http_server INFO[2022-09-23T16:57:47Z] Server RTSP start call=Start func=RTSPServer module=rtsp_server INFO[2022-09-23T16:57:47Z] Server start success a wait signals func=main module=main INFO[2022-09-23T16:58:08Z] Server receive signalterminated func=main module=main INFO[2022-09-23T16:58:10Z] Server stop working by signal func=main module=main 2022/09/23 16:58:15 Set ICEServers [stun:stun.l.google.com:19302] 2022/09/23 16:58:15 Set ICEServers [stun:stun.l.google.com:19302]

i8beef commented 1 year ago

I am also running in docker, TCP only mode.

JeDiE99 commented 1 year ago
  1. Try without docker, work or not + disable firewall for test
  2. Try codec alaw or opus
  3. Need logs in moment when you connect to RTSPtoWeb (when start play video) like this сен 23 20:28:27 m10 rtsp-to-web[11563]: time="2022-09-23T20:28:27+03:00" level=info msg="Run stream" call=Run channel=A41437A7CE45_0 func=StreamServerRunStreamDo module=core stream=A41437A7CE45 сен 23 20:28:27 m10 rtsp-to-web[11563]: 2022/09/23 20:28:27 Set ICEServers [stun:stun.l.google.com:19302] сен 23 20:28:27 m10 rtsp-to-web[11563]: time="2022-09-23T20:28:27+03:00" level=info msg="Success connection RTSP" call=Start channel=A41437A7CE45_0 func=StreamServerRunStream module=core stream=A41437A7CE45
JeDiE99 commented 1 year ago

If codec not supported you get this: сен 23 20:30:24 m10 rtsp-to-web[5048]: time="2022-09-23T20:30:24+03:00" level=info msg="Success connection RTSP" call=Start channel=W2D5M07Z022110043_0 func=StreamServerRunStream module=core stream=W2D5M07Z022110043 сен 23 20:30:24 m10 rtsp-to-web[5048]: 2022/09/23 20:30:24 Set ICEServers [stun:stun.l.google.com:19302] сен 23 20:30:24 m10 rtsp-to-web[5048]: 2022/09/23 20:30:24 WebRTC Ignore Audio Track codec not supported WebRTC support only PCM_ALAW or PCM_MULAW

i8beef commented 1 year ago

Well I am NOT getting that in the logs... and VLC is seeing the audio stream just fine from the same stream...

I can try opus and see if it makes a difference.

i8beef commented 1 year ago

Switched source stream to opus. No change. Attaching my config here in case you see something obvious that I haven't been able to pinpoint:

{
  "server": {
    "debug": true,
    "log_level": "info",
    "http_demo": true,
    "http_debug": false,
    "http_login": "demo",
    "http_password": "demo",
    "http_port": ":8084",
    "ice_servers": ["stun:stun.l.google.com:19302"],
    "rtsp_port": ":5541",
    "defaults": {
      "audio": true
    }
  },
  "streams": {
    "driveway": {
      "name": "Driveway",
      "channels": {
        "0": {
          "name": "ch1",
          "url": "rtsp://MYURL",
          "on_demand": true,
          "debug": false,
          "audio": true,
          "status": 1
        }
      }
    },
    "frontdoor": {
      "name": "Front Door",
      "channels": {
        "0": {
          "name": "ch1",
          "url": "rtsp://MYURL",
          "on_demand": true,
          "debug": false,
          "audio": true,
          "status": 1
        }
      }
    }
  },
  "channel_defaults": {
    "on_demand": true
  }
}
JeDiE99 commented 1 year ago

Need logs, first

i8beef commented 1 year ago

I gave you the logs above already? Which logs are you looking for?

JeDiE99 commented 1 year ago

Full logs(rtsp-to-web) when you start watch webrtc video

i8beef commented 1 year ago

But thats what I gave you. Here is the complete log from starting up the docker image to connecting and beginning to play the stream again:

ERRO[2022-09-25T22:04:56Z] WebRTC Client Offline call=WritePacket channel=0 func=HTTPAPIServerStreamWebRTC module=http_webrtc stream=frontdoor INFO[2022-09-25T22:04:56Z] Server receive signalterminated func=main module=main INFO[2022-09-25T22:04:56Z] Stream exit by signal or not client call=StreamServerRunStream channel=0 func=StreamServerRunStreamDo module=core stream=driveway INFO[2022-09-25T22:04:56Z] Stream exit by signal or not client call=StreamServerRunStream channel=0 func=StreamServerRunStreamDo module=core stream=frontdoor INFO[2022-09-25T22:04:58Z] Server stop working by signal func=main module=main INFO[2022-09-25T22:04:58Z] Server CORE start func=main module=main INFO[2022-09-25T22:04:58Z] Server HTTP start call=Start func=RTSPServer module=http_server INFO[2022-09-25T22:04:58Z] Server RTSP start call=Start func=RTSPServer module=rtsp_server INFO[2022-09-25T22:04:58Z] Server start success a wait signals func=main module=main INFO[2022-09-25T22:05:20Z] Run stream call=Run channel=0 func=StreamServerRunStreamDo module=core stream=frontdoor INFO[2022-09-25T22:05:20Z] Success connection RTSP call=Start channel=0 func=StreamServerRunStream module=core stream=frontdoor 2022/09/25 22:05:20 Set ICEServers [stun:stun.l.google.com:19302]

JeDiE99 commented 1 year ago

Looks good Do you here camera sound in vlc?

i8beef commented 1 year ago

I do. But still seemingly no sound from the RTSPtoWeb interface, or my own test page.

To be clear, I have sound in the RTSP stream, NOT in the WebRTC stream.

nemosupremo commented 1 year ago

It looks like RtspptoWeb doesn't support audio over webrtc? I see here that packets that aren't h264 are just dropped?:

https://github.com/deepch/vdk/blob/b0aae43f1015fba39cd66af9b66dd6ec678bf99e/format/webrtc/adapter.go#L131