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

WebRTC stream suddenly stops working from time to time #1461

Open
nicoverali opened this issue Nov 14, 2024 · 7 comments
Open

WebRTC stream suddenly stops working from time to time #1461

nicoverali opened this issue Nov 14, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@nicoverali
Copy link

nicoverali commented Nov 14, 2024

Hello, I'm using go2rtc to get the stream of a Reolink Doorbell camera, and then I consume that from HomeAssistant. It works for about a week, and then it usually crashes and stops working, so I have to restart the server manually.

This is the config:

api:
  listen: "0.0.0.0:1984"    # default ":1984", HTTP API port ("" - disabled)
  username: ""  # default "", Basic auth for WebUI
  password: ""   # default "", Basic auth for WebUI
  origin: "*"        # default "", allow CORS requests (only * supported)

streams:
  doorbell-sub:
    - rtsp://user:[email protected]:554/h264Preview_01_sub
    - ffmpeg:doorbell-sub#audio=opus#audio=volume
    
ffmpeg:
  bin: ffmpeg  # path to ffmpeg binary
  volume: "-af \"volume=10\""

And then this is what I'm seeing in the info page of that stream:

{
  "producers": [
    {
      "id": 307,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "192.168.2.102:554",
      "url": "rtsp://user:[email protected]:554/h264Preview_01_sub",
      "sdp": "v=0\r\no=- 1731214857266085 1 IN IP4 192.168.2.102\r\ns=Session streamed by \"preview\"\r\nt=0 0\r\na=tool:BC Streaming Media v202210012022.10.01\r\na=type:broadcast\r\na=control:*\r\na=range:npt=now-\r\na=x-qt-text-nam:Session streamed by \"preview\"\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:96 H264/90000\r\na=range:npt=now-\r\na=fmtp:96 packetization-mode=1;profile-level-id=640033;sprop-parameter-sets=Z2QAM6wVFKCgPZA=,aO48sA==\r\na=recvonly\r\na=control:track1\r\nm=audio 0 RTP/AVP 97\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:97 MPEG4-GENERIC/16000\r\na=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408;\r\na=recvonly\r\na=control:track2\r\nm=audio 0 RTP/AVP 8\r\na=control:track3\r\na=rtpmap:8 PCMA/8000\r\na=sendonly",
      "user_agent": "go2rtc/1.9.6",
      "medias": [
        "video, recvonly, H264",
        "audio, recvonly, MPEG4-GENERIC/16000",
        "audio, sendonly, PCMA/8000"
      ],
      "receivers": [
        {
          "id": 309,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 51,
            "profile": "High"
          },
          "childs": [
            320,
            322,
            324,
            326,
            328,
            330,
            332,
            334,
            336,
            338,
            340,
            342,
            344,
            346,
            348,
            350,
            352,
            354,
            356,
            358,
            360,
            362,
            364,
            366,
            368,
            370,
            372,
            374,
            376,
            378,
            380,
            382,
            384,
            386,
            388,
            390,
            393,
            396
          ],
          "bytes": 7443497585,
          "packets": 6559290
        },
        {
          "id": 313,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "childs": [
            394
          ],
          "bytes": 1220498412,
          "packets": 2365307
        }
      ],
      "bytes_recv": 8773997369
    },
    {
      "id": 315,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "127.0.0.1:38130 forwarded 127.0.0.1:8554",
      "source": "exec:ffmpeg -hide_banner -v error -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://127.0.0.1:8554/doorbell-sub?audio -map 0:a:0? -c:a:0 libopus -application:a:0 lowdelay -min_comp 0 -af \"volume=10\" -vn -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:8554/70acbc2b73c69b4881ece3dea1070b68",
      "url": "rtsp://127.0.0.1:8554/doorbell-sub?audio",
      "sdp": "v=0\r\no=- 0 0 IN IP4 127.0.0.1\r\ns=go2rtc/1.9.6\r\nc=IN IP4 127.0.0.1\r\nt=0 0\r\na=tool:libavformat 60.16.100\r\nm=audio 0 RTP/AVP 96\r\nb=AS:64\r\na=rtpmap:96 opus/48000/2\r\na=control:streamid=0\r\n",
      "user_agent": "ffmpeg/go2rtc",
      "medias": [
        "audio, recvonly, OPUS/48000/2"
      ],
      "receivers": [
        {
          "id": 316,
          "codec": {
            "channels": 2,
            "codec_name": "opus",
            "codec_type": "audio",
            "sample_rate": 48000
          },
          "bytes": 2287111,
          "packets": 13212
        }
      ],
      "bytes_recv": 2447139
    }
  ],
  "consumers": [
    {
      "id": 312,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "127.0.0.1:38120",
      "sdp": "v=0\r\no=- 1 1 IN IP4 0.0.0.0\r\ns=go2rtc/1.9.6\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=audio 0 RTP/AVP 96\r\na=rtpmap:96 MPEG4-GENERIC/16000\r\na=fmtp:96 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408;\r\na=control:trackID=0\r\n",
      "user_agent": "go2rtc/ffmpeg",
      "medias": [
        "audio, sendonly, ANY"
      ],
      "senders": [
        {
          "id": 314,
          "codec": {
            "codec_name": "aac",
            "codec_type": "audio",
            "sample_rate": 16000
          },
          "parent": 313,
          "bytes": 2131080,
          "packets": 4130
        }
      ],
      "bytes_send": 2197160
    }
  ]
}
}

We can probably remove HomeAssistant from the formula, because although that's what I'm using to consume the stream, if I go to the go2rtc panel, and click on stream it also fails to load, it keeps loading forever.

Screenshot 2024-11-14 at 11 28 05 AM

It looks like the websocket connection is not responding, maybe ?

@AlexxIT AlexxIT added the bug Something isn't working label Nov 14, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Nov 14, 2024

So many childs is a big problem. Don't know yet why this can happen.

@AlexxIT AlexxIT self-assigned this Nov 14, 2024
@nicoverali
Copy link
Author

I can provide some more details:

  • I'm currently using version 1.9.6, before I was using version 1.8.2, and this issue was not present
  • Most consumers are mobile, using HomeAssistant app, specifically iOS devices
  • The common use pattern is: open HomeAssistant -> tap on a button to show the Camera dashboard -> then move to another iOS app. The HomeAssistant app is usually not explicitly closed

I can also send you the HomeAssistant card configuration in case it helps, but I believe it's pretty straightforward

type: custom:webrtc-camera
url: doorbell-sub
mode: webrtc
media: video,audio

@seydx
Copy link

seydx commented Nov 14, 2024

So many childs is a big problem. Don't know yet why this can happen.

Its related to self referencing streams i think which should be fixed in v1.9.7. After closing the stream, the rtsp consumer from ffmpeg is still present. And if there is an issue with ffmpeg, the childs are not cleaned up

@nicoverali
Copy link
Author

So many childs is a big problem. Don't know yet why this can happen.

Its related to self referencing streams i think which should be fixed in v1.9.7. After closing the stream, the rtsp consumer from ffmpeg is still present. And if there is an issue with ffmpeg, the childs are not cleaned up

I can try upgrading to v1.9.7 and check if it happens again. I'll let you know in a few days

@nicoverali
Copy link
Author

@AlexxIT @seydx I've upgrade to v1.9.7 and the same thing happened again

{
   "producers":[
      {
         "id":2,
         "format_name":"rtsp",
         "protocol":"rtsp+tcp",
         "remote_addr":"192.168.2.102:554",
         "url":"rtsp://user:[email protected]:554/h264Preview_01_sub",
         "sdp":"v=0\r\no=- 1731922670403090 1 IN IP4 192.168.0.3\r\ns=Session streamed by \"preview\"\r\nt=0 0\r\na=tool:BC Streaming Media v202210012022.10.01\r\na=type:broadcast\r\na=control:*\r\na=range:npt=now-\r\na=x-qt-text-nam:Session streamed by \"preview\"\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=640033;sprop-parameter-sets=Z2QAM6wVFKCgPZA=,aO48sA==\r\na=recvonly\r\na=control:track1\r\nm=audio 0 RTP/AVP 97\r\nc=IN IP4 0.0.0.0\r\nb=AS:8192\r\na=rtpmap:97 MPEG4-GENERIC/16000\r\na=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408;\r\na=recvonly\r\na=control:track2\r\nm=audio 0 RTP/AVP 8\r\na=control:track3\r\na=rtpmap:8 PCMA/8000\r\na=sendonly",
         "user_agent":"go2rtc/1.9.7",
         "medias":[
            "video, recvonly, H264",
            "audio, recvonly, MPEG4-GENERIC/16000",
            "audio, sendonly, PCMA/8000"
         ],
         "receivers":[
            {
               "id":3,
               "codec":{
                  "codec_name":"h264",
                  "codec_type":"video",
                  "level":51,
                  "profile":"High"
               },
               "childs":[
                  21,
                  23,
                  25,
                  27,
                  29,
                  31,
                  33,
                  37,
                  41,
                  45,
                  47,
                  49,
                  51,
                  53,
                  55,
                  57,
                  59,
                  61,
                  63,
                  65,
                  67,
                  71,
                  76,
                  77,
                  81,
                  83,
                  85,
                  88,
                  91
               ],
               "bytes":2206397467,
               "packets":1960259
            },
            {
               "id":6,
               "codec":{
                  "codec_name":"aac",
                  "codec_type":"audio",
                  "sample_rate":16000
               },
               "childs":[
                  89
               ],
               "bytes":361735092,
               "packets":701037
            }
         ],
         "senders":[
            {
               "id":14,
               "codec":{
                  "codec_name":"pcm_alaw",
                  "codec_type":"audio",
                  "sample_rate":8000
               },
               "parent":13,
               "bytes":100000,
               "packets":625
            },
            {
               "id":35,
               "codec":{
                  "codec_name":"pcm_alaw",
                  "codec_type":"audio",
                  "sample_rate":8000
               },
               "parent":34
            },
            {
               "id":40,
               "codec":{
                  "codec_name":"pcm_alaw",
                  "codec_type":"audio",
                  "sample_rate":8000
               },
               "parent":38
            },
            {
               "id":43,
               "codec":{
                  "codec_name":"pcm_alaw",
                  "codec_type":"audio",
                  "sample_rate":8000
               },
               "parent":42
            },
            {
               "id":69,
               "codec":{
                  "codec_name":"pcm_alaw",
                  "codec_type":"audio",
                  "sample_rate":8000
               },
               "parent":68
            },
            {
               "id":75,
               "codec":{
                  "codec_name":"pcm_alaw",
                  "codec_type":"audio",
                  "sample_rate":8000
               },
               "parent":72
            },
            {
               "id":79,
               "codec":{
                  "codec_name":"pcm_alaw",
                  "codec_type":"audio",
                  "sample_rate":8000
               },
               "parent":78
            }
         ],
         "bytes_recv":2601180131,
         "bytes_send":100880
      },
      {
         "id":8,
         "format_name":"rtsp",
         "protocol":"rtsp+tcp",
         "remote_addr":"127.0.0.1:48772 forwarded 127.0.0.1:8554",
         "source":"exec:ffmpeg -hide_banner -v error -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://127.0.0.1:8554/doorbell-sub?audio&source=ffmpeg:doorbell-sub%23audio%3Dopus%23audio%3Dvolume -map 0:a:0? -c:a:0 libopus -application:a:0 lowdelay -min_comp 0 -af \"volume=10\" -vn -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:8554/08ad235e02668038fe4c37b715dfb357",
         "url":"rtsp://127.0.0.1:8554/doorbell-sub?audio&source=ffmpeg:doorbell-sub%23audio%3Dopus%23audio%3Dvolume",
         "sdp":"v=0\r\no=- 0 0 IN IP4 127.0.0.1\r\ns=go2rtc/1.9.7\r\nc=IN IP4 127.0.0.1\r\nt=0 0\r\na=tool:libavformat 60.16.100\r\nm=audio 0 RTP/AVP 96\r\nb=AS:64\r\na=rtpmap:96 opus/48000/2\r\na=control:streamid=0\r\n",
         "user_agent":"ffmpeg/go2rtc",
         "medias":[
            "audio, recvonly, OPUS/48000/2"
         ],
         "receivers":[
            {
               "id":9,
               "codec":{
                  "channels":2,
                  "codec_name":"opus",
                  "codec_type":"audio",
                  "sample_rate":48000
               },
               "bytes":69736,
               "packets":358
            }
         ],
         "bytes_recv":74088
      }
   ],
   "consumers":[
      {
         "id":16,
         "format_name":"rtsp",
         "protocol":"rtsp+tcp",
         "remote_addr":"127.0.0.1:55860",
         "source":"ffmpeg:doorbell-sub#audio=opus#audio=volume",
         "sdp":"v=0\r\no=- 1 1 IN IP4 0.0.0.0\r\ns=go2rtc/1.9.7\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\nm=audio 0 RTP/AVP 96\r\na=rtpmap:96 MPEG4-GENERIC/16000\r\na=fmtp:96 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408;\r\na=control:trackID=0\r\n",
         "user_agent":"go2rtc/ffmpeg",
         "medias":[
            "audio, sendonly, ANY"
         ],
         "senders":[
            {
               "id":17,
               "codec":{
                  "codec_name":"aac",
                  "codec_type":"audio",
                  "sample_rate":16000
               },
               "parent":6,
               "bytes":1910748,
               "packets":3703
            }
         ],
         "bytes_send":1969996
      }
   ]
}

@seydx
Copy link

seydx commented Nov 19, 2024

@nicoverali
Copy link
Author

@nicoverali

can you try this one: https://github.com/seydx/go2rtc/actions/runs/11920040811

Sure. It took like 3 days to crash last time, so I'll let you know in a couple of days.

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

No branches or pull requests

3 participants