Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Good audio on MSE but choppy audio on WebRTC #410

Closed
felipecrs opened this issue May 4, 2023 · 11 comments
Closed

Good audio on MSE but choppy audio on WebRTC #410

felipecrs opened this issue May 4, 2023 · 11 comments
Labels
audio bug Something isn't working webrtc
Milestone

Comments

@felipecrs
Copy link
Contributor

felipecrs commented May 4, 2023

Hi,

I installed go2rtc (the add-on) for my brother, and he has an old Hikvision DVR. I was able to import his 16 cameras just fine to go2rtc, but audio isn't working very well.

See (and listen) to this demo:

chrome_xWpi1GWgqG.mp4

Basically the audio is very good on MSE, but very bad on WebRTC.

webrtc:
  listen: ":8555"

streams:
    camera_01:
      - rtsp://admin:pass@192.168.1.20/Streaming/Channels/101
{
  "producers": [
    {
      "type": "RTSP active producer",
      "url": "rtsp://192.168.1.20:554/Streaming/Channels/101",
      "remote_addr": "192.168.1.20:554",
      "user_agent": "go2rtc/1.5.0",
      "medias": [
        "video, recvonly, H.264 High 3.1",
        "audio, recvonly, PCMU/8000"
      ],
      "receivers": [
        "96 H264, bytes=1709551, senders=1",
        "0 PCMU/8000, bytes=158720, senders=1"
      ],
      "recv": 1880676
    }
  ],
  "consumers": [
    {
      "type": "WebRTC/WebSocket async passive consumer",
      "remote_addr": "udp4 srflx 179.106.189.52:57785 related 0.0.0.0:0",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
      "medias": [
        "video, sendonly, VP8, RTX, VP9, H264, AV1, RED, ULPFEC, FLEXFEC-03",
        "audio, sendonly, OPUS/48000/2, RED/48000/2, G722/8000, PCMU/8000, PCMA/8000, CN/8000, TELEPHONE-EVENT/48000, TELEPHONE-EVENT/8000, L16"
      ],
      "senders": [
        "102 H264, bytes=442838, receivers=1",
        "0 PCMU/8000, bytes=45440, receivers=1"
      ],
      "send": 495741
    }
  ]
}

There are no errors in the logs. Let me know if I should increase some specific logs.

@felipecrs
Copy link
Contributor Author

PS: Running on a Raspberry Pi 3b+

@NickM-27
Copy link
Contributor

NickM-27 commented May 4, 2023

maybe try different audio codecs from the DVR if it's supported?

@felipecrs
Copy link
Contributor Author

I had looked into it already... the DVR doesn't support changing audio codecs apparently.

@felipecrs
Copy link
Contributor Author

When consuming with MSE:

{
  "producers": [
    {
      "type": "RTSP active producer",
      "url": "rtsp://192.168.1.20:554/Streaming/Channels/101",
      "remote_addr": "192.168.1.20:554",
      "user_agent": "go2rtc/1.5.0",
      "medias": [
        "video, recvonly, H.264 High 3.1",
        "audio, recvonly, PCMU/8000"
      ],
      "receivers": [
        "96 H264, bytes=250612, senders=1",
        "0 PCMU/8000, bytes=21120, senders=1"
      ],
      "recv": 273420
    }
  ],
  "consumers": [
    {
      "type": "MP4 passive consumer",
      "remote_addr": "179.106.189.52, 172.30.33.2, 172.30.32.1, 172.30.32.2:52518",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
      "medias": [
        "video, sendonly, H264, H265",
        "audio, sendonly, MPEG4-GENERIC, PCMA, PCMU, L16, OPUS"
      ],
      "senders": [
        "96 H264, bytes=250612, receivers=1",
        "0 FLAC/8000, bytes=21120, receivers=1"
      ],
      "send": 304412
    }
  ]
}

@felipecrs
Copy link
Contributor Author

Oh, by the way I also tried:

streams:
    camera_01:
      - ffmpeg:rtsp://admin:pass@192.168.1.20/Streaming/Channels/101#video=copy#audio=opus

But the exact same problem happened (MSE works, WebRTC is choppy).

{
  "producers": [
    {
      "type": "RTSP passive producer",
      "url": "rtsp://127.0.0.1:8554/5321da5826e23a276a3ebfaeab79d0c3",
      "remote_addr": "127.0.0.1:60392",
      "user_agent": "ffmpeg/go2rtc",
      "medias": [
        "video, recvonly, H.264 High 3.1",
        "audio, recvonly, OPUS/48000/2"
      ],
      "receivers": [
        "96 H264, bytes=926436, senders=1",
        "97 OPUS/48000/2, bytes=91951, senders=1"
      ],
      "recv": 1032400
    }
  ],
  "consumers": [
    {
      "type": "WebRTC/WebSocket async passive consumer",
      "remote_addr": "udp4 srflx 179.106.189.52:60927 related 0.0.0.0:0",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
      "medias": [
        "video, sendonly, VP8, RTX, VP9, H264, AV1, RED, ULPFEC, FLEXFEC-03",
        "audio, sendonly, OPUS/48000/2, RED/48000/2, G722/8000, PCMU/8000, PCMA/8000, CN/8000, TELEPHONE-EVENT/48000, TELEPHONE-EVENT/8000, L16"
      ],
      "senders": [
        "102 H264, bytes=926436, receivers=1",
        "111 OPUS/48000/2, bytes=91951, receivers=1"
      ],
      "send": 1034539
    }
  ]
}

@felipecrs
Copy link
Contributor Author

felipecrs commented May 4, 2023

I initially thought it was because my Rpi was too slow, but I don't think it's the case because:

  1. I tried reducing the framerate to like <5 FPS on the DVR
  2. I tried reducing the resolution to 320x240 on the DVR

None helped the audio in WebRTC.

@AlexxIT AlexxIT added the bug Something isn't working label May 5, 2023
@felipecrs
Copy link
Contributor Author

Maybe this is related to #387.

@felipecrs
Copy link
Contributor Author

Probably related to #361 as well.

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 11, 2023

@AlexxIT AlexxIT closed this as completed Jul 11, 2023
@felipecrs
Copy link
Contributor Author

Issue is fixed indeed! Thanks a ton!

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 11, 2023

Very stupid fix. I think no one knows why it is works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio bug Something isn't working webrtc
Projects
None yet
Development

No branches or pull requests

3 participants