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
5.05k stars 401 forks source link

RTSP wrong input for chinese camera #231

Closed felipecrs closed 1 year ago

felipecrs commented 1 year ago

Hi, I have 10 cameras but only one of this model (INQMEGA IL-PTZ381-2M-C: https://aliexpress.com/item/4000780447748.html), and it keeps causing go2rt to send this in the logs:

12:15:30.219 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:16:33.515 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" 

It mentions av0, but if I remove av0 from my go2rtc config and put av1 instead, it errors the same but with av1 now.

I did my best to isolate the issue. This is the minimal config and environment to reproduce it:

log:
  level: debug
  api: debug
  exec: debug
  ngrok: debug
  rtsp: debug
  streams: debug
  webrtc: debug

streams:
  rua:
    - rtsp://admin:12345@192.168.1.33:554/0/av1
    - "ffmpeg:rua#audio=aac"
  rua_hd:
    - rtsp://admin:12345@192.168.1.33:554/0/av0
    - rtsp://127.0.0.1:8554/rua?audio=aac

https://user-images.githubusercontent.com/29582865/216083346-4269f618-4556-4893-8669-636064f69f41.mp4

{
  "producers": [
    {
      "type": "RTSP source",
      "url": "rtsp://192.168.1.33:554/0/av1",
      "remote_addr": "192.168.1.33:554",
      "user_agent": "go2rtc/1.1.1",
      "medias": [
        "video, sendonly, 96 H264/90000",
        "audio, sendonly, 8 PCMA/8000"
      ],
      "tracks": [
        "96 H264/90000, sinks=2",
        "8 PCMA/8000, sinks=1"
      ],
      "recv": 6683208
    },
    {
      "type": "RTSP source",
      "url": "rtsp://localhost:8554/f32a01ce52b009cdf58ea3f09916514f",
      "remote_addr": "[::1]:38472",
      "user_agent": "ffmpeg/go2rtc",
      "medias": [
        "audio, sendonly, 96 MPEG4-GENERIC/8000"
      ],
      "tracks": [
        "96 MPEG4-GENERIC/8000, sinks=2"
      ],
      "recv": 1105530
    }
  ],
  "consumers": [
    {
      "type": "RTSP client",
      "url": "rtsp://localhost:8554/rua?audio",
      "remote_addr": "[::1]:38460",
      "user_agent": "go2rtc/ffmpeg",
      "medias": [
        "audio, recvonly, 96 PCMA/8000"
      ],
      "tracks": [
        "96 PCMA/8000, sinks=1"
      ],
      "send": 2554408
    },
    {
      "type": "RTSP client",
      "url": "rtsp://home.felipecrs.com:8554/rua?mp4",
      "remote_addr": "192.168.1.15:46476",
      "user_agent": "LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)",
      "medias": [
        "video, recvonly, 96 H264/90000",
        "audio, recvonly, 97 MPEG4-GENERIC/8000"
      ],
      "tracks": [
        "96 H264/90000, sinks=2",
        "97 MPEG4-GENERIC/8000, sinks=2"
      ],
      "recv": 6832,
      "send": 5232622
    },
    {
      "type": "RTSP client",
      "url": "rtsp://127.0.0.1:8554/rua?audio=aac",
      "remote_addr": "127.0.0.1:38440",
      "medias": [
        "audio, recvonly, 96 MPEG4-GENERIC/8000"
      ],
      "tracks": [
        "96 MPEG4-GENERIC/8000, sinks=2"
      ],
      "send": 1053958
    },
    {
      "type": "RTSP client",
      "url": "rtsp://home.felipecrs.com:8554/rua?video=copy",
      "remote_addr": "192.168.1.15:46531",
      "user_agent": "LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)",
      "medias": [
        "video, recvonly, 96 H264/90000"
      ],
      "tracks": [
        "96 H264/90000, sinks=2"
      ],
      "recv": 2352,
      "send": 2753232
    }
  ]
}
{
  "producers": [
    {
      "type": "RTSP source",
      "url": "rtsp://192.168.1.33:554/0/av0",
      "remote_addr": "192.168.1.33:554",
      "user_agent": "go2rtc/1.1.1",
      "medias": [
        "video, sendonly, 96 H264/90000",
        "audio, sendonly, 8 PCMA/8000"
      ],
      "tracks": [
        "96 H264/90000, sinks=2",
        "8 PCMA/8000, sinks=1"
      ],
      "recv": 2226459
    },
    {
      "type": "RTSP source",
      "url": "rtsp://127.0.0.1:8554/rua?audio=aac",
      "remote_addr": "127.0.0.1:8554",
      "user_agent": "go2rtc/1.1.1",
      "medias": [
        "audio, sendonly, 96 MPEG4-GENERIC/8000"
      ],
      "tracks": [
        "96 MPEG4-GENERIC/8000, sinks=1"
      ],
      "recv": 522608
    }
  ],
  "consumers": [
    {
      "type": "RTSP client",
      "url": "rtsp://home.felipecrs.com:8554/rua_hd?mp4",
      "remote_addr": "192.168.1.15:46485",
      "user_agent": "LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)",
      "medias": [
        "video, recvonly, 96 H264/90000",
        "audio, recvonly, 97 MPEG4-GENERIC/8000"
      ],
      "tracks": [
        "96 H264/90000, sinks=2",
        "97 MPEG4-GENERIC/8000, sinks=1"
      ],
      "recv": 3304,
      "send": 11449917
    },
    {
      "type": "RTSP client",
      "url": "rtsp://home.felipecrs.com:8554/rua_hd?video=copy\u0026audio=copy",
      "remote_addr": "192.168.1.15:46520",
      "user_agent": "LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)",
      "medias": [
        "video, recvonly, 96 H264/90000",
        "audio, recvonly, 97 PCMA/8000"
      ],
      "tracks": [
        "96 H264/90000, sinks=2",
        "97 PCMA/8000, sinks=1"
      ],
      "recv": 1736,
      "send": 6512208
    }
  ]
}

Logs:

12:10:53.148 INF go2rtc version 1.1.1 linux/amd64
12:10:53.150 INF [api] listen addr=:1984
12:10:53.151 INF [rtsp] listen addr=:8554
12:10:53.153 INF [srtp] listen addr=:8443
12:10:53.153 INF [webrtc] listen addr=:8555
12:11:09.626 DBG [rtsp] new consumer stream=rua
12:11:09.626 DBG [streams] probe producer url=rtsp://admin:12345@192.168.1.33:554/0/av1
12:11:09.633 DBG [streams] probe producer url=ffmpeg:rua#audio=aac
12:11:09.633 DBG [exec] run url="exec:ffmpeg -hide_banner -v error -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i rtsp://localhost:8554/rua?audio -vn -c:a aac -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp rtsp://localhost:8554/f32a01ce52b009cdf58ea3f09916514f"
12:11:09.672 DBG [rtsp] new consumer stream=rua
12:11:09.674 DBG [streams] start producer url=rtsp://admin:12345@192.168.1.33:554/0/av1
12:11:09.768 DBG [exec] run launch=134.686391ms
12:11:09.768 DBG [streams] start producer url=ffmpeg:rua#audio=aac
12:11:24.047 DBG [rtsp] new consumer stream=rua_hd
12:11:24.047 DBG [streams] probe producer url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:11:24.054 DBG [streams] probe producer url=rtsp://127.0.0.1:8554/rua?audio=aac
12:11:24.054 DBG [rtsp] new consumer stream=rua
12:11:24.054 DBG [streams] start producer url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:11:24.054 DBG [streams] start producer url=rtsp://127.0.0.1:8554/rua?audio=aac
12:12:37.163 DBG [rtsp] new consumer stream=rua_hd
12:12:37.163 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:12:52.454 DBG [rtsp] new consumer stream=rua
12:12:58.259 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:12:58.265 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:04.343 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:04.343 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:07.362 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:07.362 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:07.762 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:07.766 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:08.085 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:08.085 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:16.468 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:16.470 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:19.444 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:19.444 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:22.495 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:13:22.495 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:29.265 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:29.271 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:32.287 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:32.291 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:32.706 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:32.716 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:41.330 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:41.336 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:47.382 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:47.382 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:56.455 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:14:56.460 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:15:08.655 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:15:08.660 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:15:29.847 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:15:29.853 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:15:30.213 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:15:30.219 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:16:33.515 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av0
12:16:33.515 DBG [streams] reconnect to url=rtsp://admin:12345@192.168.1.33:554/0/av0
felipecrs commented 1 year ago

More details:

felipecrs commented 1 year ago

Oh no! I think I'm connecting to my camera using its wi-fi interface even though it's wired! I'll check this.

felipecrs commented 1 year ago

Could that be the reason of the issue?

NickM-27 commented 1 year ago

Could that be the reason of the issue?

One of my reolink cams (Reolink Duo 2) has a much worse time over WiFi producing a lot of these errors meanwhile on ethernet it is rock solid

felipecrs commented 1 year ago

Ok, update:

Very surprisingly, my camera uses the same mac address for both wi-fi and ethernet. I could probably reset it in the Tuya app so that it would lose the wi-fi credentials, however, I decided to just configure my access point to block wi-fi access to its mac address.

I'll monitor now if the issue comes back.

felipecrs commented 1 year ago

Ok... the issue happens even when I'm 100% sure that it's connected over ethernet. =/

And I think this is expected (not to be related to wi-fi in my case), because my wi-fi connection is very strong and reliable. I have other 2 cameras connected through wi-fi (different model however) that never triggers this RTSP wrong input issue.

2023-02-01 17:33:17.325867081  14:33:17.323 INF go2rtc version 1.1.0 linux/amd64
2023-02-01 17:33:17.325957193  14:33:17.323 INF [api] listen addr=:1984
2023-02-01 17:33:17.325961195  14:33:17.324 INF [rtsp] listen addr=:8554
2023-02-01 17:33:17.325963577  14:33:17.325 INF [srtp] listen addr=:8443
2023-02-01 17:33:17.325965735  14:33:17.325 INF [webrtc] listen addr=:8555
2023-02-01 17:34:14.742230610  14:34:14.741 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av1
2023-02-01 17:34:23.900767023  14:34:23.900 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av1
2023-02-01 17:34:24.215586332  14:34:24.215 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av1
2023-02-01 17:34:24.595960394  14:34:24.594 WRN github.com/AlexxIT/go2rtc/cmd/streams/producer.go:132 > error="RTSP wrong input" url=rtsp://admin:12345@192.168.1.33:554/0/av1
NickM-27 commented 1 year ago

And I think this is expected (not to be related to wi-fi in my case), because my wi-fi connection is very strong and reliable.

Not speaking of your case but I'd say that's not really the case. In my example I was testing the reolink camera on a desk in the same room as my WiFi router. I don't think (at least in my case) it has to do with bad WiFi just how the data is sent.

also, RTSP Wrong Input means that the camera is sending invalid TCP packets

felipecrs commented 1 year ago

I don't think (at least in my case) it has to do with bad WiFi just how the data is sent.

I see. That's a valid point.

also, RTSP Wrong Input means that the camera is sending invalid TCP packets

Oh crap. I hope the only solution for this issue isn't replacing its firmware then.

AlexxIT commented 1 year ago

I need access to this stream.

felipecrs commented 1 year ago

There you go:

rtsp://admin:12345@179.106.189.52:63499/0/av0
NickM-27 commented 1 year ago

@felipecrs I believe AlexxIt meant access to a live stream from the camera directly

felipecrs commented 1 year ago

Well... isn't that what I sent? lol

AlexxIT commented 1 year ago

There is no response from your stream. You can use ngrok tunnel and send link in private msg. Check contacts in github profile.

felipecrs commented 1 year ago

Sorry about that. I'm suffering of a major outage from my ISP, that's why it must not be working for you. I'll let you know once my ISP stabilizes.

felipecrs commented 1 year ago

It's back on business now, if you want to try.

AlexxIT commented 1 year ago

Does this camera work anywhere at all? It sends all sorts of garbage at the place where the frame should end. Maybe it only works in UDP mode.

felipecrs commented 1 year ago

Well... yes. This RTSP wrong input just keeps popping in my go2rtc logs, but it appears to be working normally. Also, I'm using this very same camera in Frigate since years, when there was no go2rtc.

felipecrs commented 1 year ago

But, if you think it's not worth to spend more time on it, don't worry, I'm okay 😅

felipecrs commented 1 year ago

I mean, even in go2rtc it appears to be working normally if I don't check the logs.

AlexxIT commented 1 year ago

Maybe with local connection it can work better. Even via TCP. I think frames should be read very fast.

felipecrs commented 1 year ago

Alright, thanks a lot for the investigation anyway. Can I close this issue and disable the port forward to the camera on my router then?

AlexxIT commented 1 year ago

Ok