bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
10.94k stars 1.42k forks source link

Ondemand proxy stream start/stop every 10 seconds #949

Closed clee604 closed 2 years ago

clee604 commented 2 years ago

Which version are you using?

v0.18.3 and v0.18.4 seems to be affected, v0.18.2 works fine

Which operating system are you using?

Describe the issue

I use rtsp-simple-server to proxy some home webcam feeds to save wifi bandwidth and to prevent overload of the camera when there are multiple clients connected to it. Since 0.18.3+, the proxy stream seems to destroyed and recreated every 10 seconds. I've rolled back to 0.18.2 and this works fine. I've tested this using docker on both an amd64 and arm7 device connected by ethernet.

Describe how to replicate the issue

I upgraded from my 0.18.2 docker container to both 0.18.3 and 0.18.4 via recreating the container but pointing to same configuration file.

I use the following path config with my credentials and ip omitted. The camera in question is an Eufy indoor cam but I've tried it with my wyze and other rtsp cameras with the same results.

paths: eufy: source: rtsp://[user]:[password]@[local cam ip]/live0 sourceOnDemand: yes

I am accessing the rtsp proxy feed using TinyCam, via TCP RTSP.

Did you attach the server logs?

I looked through both the debug and info logs and didn't see any errors. But the info log does seem to imply it is related to the 10 second time out.

2022/05/20 04:15:46 INF rtsp-simple-server v0.18.4

2022/05/20 04:15:46 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)

2022/05/20 04:15:46 INF [RTMP] listener opened on :1935

2022/05/20 04:15:46 INF [HLS] listener opened on :8888

2022/05/20 04:15:57 INF [RTSP] [conn [ip omitted]:44790] opened

2022/05/20 04:15:57 INF [path eufy] [rtsp source] started

2022/05/20 04:15:57 INF [path eufy] [rtsp source] ready

2022/05/20 04:15:57 INF [RTSP] [session 805985855] created by [ip omitted]:44790

2022/05/20 04:15:57 INF [RTSP] [session 805985855] is reading from path 'eufy', 1 track with TCP

2022/05/20 04:16:07 INF [path eufy] [rtsp source] stopped

2022/05/20 04:16:07 INF [RTSP] [conn [ip omitted]:44790] closed (terminated)

2022/05/20 04:16:07 INF [RTSP] [session 805985855] destroyed (terminated)

2022/05/20 04:16:07 INF [RTSP] [conn [ip omitted]:44826] opened

2022/05/20 04:16:07 INF [path eufy] [rtsp source] started

2022/05/20 04:16:08 INF [path eufy] [rtsp source] ready

2022/05/20 04:16:08 INF [RTSP] [session 609575719] created by [ip omitted]:44826

2022/05/20 04:16:08 INF [RTSP] [session 609575719] is reading from path 'eufy', 1 track with TCP

2022/05/20 04:16:18 INF [path eufy] [rtsp source] stopped

2022/05/20 04:16:18 INF [RTSP] [conn [ip omitted]:44826] closed (terminated)

2022/05/20 04:16:18 INF [RTSP] [session 609575719] destroyed (terminated)

2022/05/20 04:16:18 INF [RTSP] [conn [ip omitted]:44878] opened

2022/05/20 04:16:18 INF [path eufy] [rtsp source] started

2022/05/20 04:16:18 INF [path eufy] [rtsp source] ready

2022/05/20 04:16:18 INF [RTSP] [session 988193212] created by [ip omitted]:44878

2022/05/20 04:16:18 INF [RTSP] [session 988193212] is reading from path 'eufy', 1 track with TCP

2022/05/20 04:16:28 INF [path eufy] [rtsp source] stopped

2022/05/20 04:16:28 INF [RTSP] [conn [ip omitted]:44878] closed (terminated)

2022/05/20 04:16:28 INF [RTSP] [session 988193212] destroyed (terminated)

2022/05/20 04:16:28 INF [RTSP] [conn [ip omitted]:45014] opened

2022/05/20 04:16:28 INF [path eufy] [rtsp source] started

2022/05/20 04:16:28 INF [path eufy] [rtsp source] ready

2022/05/20 04:16:28 INF [RTSP] [session 555739947] created by [ip omitted]:45014

2022/05/20 04:16:28 INF [RTSP] [session 555739947] is reading from path 'eufy', 1 track with TCP

2022/05/20 04:16:38 INF [path eufy] [rtsp source] stopped

2022/05/20 04:16:38 INF [RTSP] [conn [ip omitted]:45014] closed (terminated)

2022/05/20 04:16:38 INF [RTSP] [session 555739947] destroyed (terminated)

2022/05/20 04:16:38 INF [RTSP] [conn [ip omitted]:45136] opened

2022/05/20 04:16:38 INF [path eufy] [rtsp source] started

2022/05/20 04:16:38 INF [path eufy] [rtsp source] ready

2022/05/20 04:16:38 INF [RTSP] [session 574926904] created by [ip omitted]:45136

2022/05/20 04:16:38 INF [RTSP] [session 574926904] is reading from path 'eufy', 1 track with TCP

2022/05/20 04:16:41 INF [RTSP] [conn [ip omitted]:45136] closed (terminated)

2022/05/20 04:16:41 INF [RTSP] [session 574926904] destroyed (teared down by [ip omitted]:45136)

Did you attach a network dump?

no

rapi3 commented 2 years ago

+1 The same problem on RPI3 and Intel x64 running Ubuntu 20.04.4 LTS ( no Docker ). all my CCTV streams are in this format: readUser: yyyyy readPass: xxxxx source: rtsp://.... sourceOnDemand: yes sourceOnDemandCloseAfter: 20s

I use celluloid and vlc on linux with network cache 3s. The stream stop after few seconds with v0.18.4. I did not tested v0.18.3 just try to update from v0.18.2 that works OK and reverted back very quick.

balajimurugesandev commented 2 years ago

+1 We are facing the same problem. The stream is active till the sourceOnDemandCloseAfter duration

tompointexe commented 2 years ago

+1

aler9 commented 2 years ago

Sorry for the regression, this has been fixed in main and a new release will be published ASAP. In the meanwhile you can use this nightly release: [link removed]

BenLocal commented 2 years ago

hls/rtmp proxy still seems to same problem,rtsp proxy is ok hls logs:

2022/05/25 14:28:50 INF rtsp-simple-server v0.18.4-1-g23ac079
2022/05/25 14:28:50 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2022/05/25 14:28:50 INF [RTMP] listener opened on :1935
2022/05/25 14:28:50 INF [HLS] listener opened on :8888
2022/05/25 14:28:52 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/index.m3u8
2022/05/25 14:28:52 INF [HLS] [muxer ch2] created
2022/05/25 14:28:52 INF [path ch2] [rtsp source] started
2022/05/25 14:28:52 INF [path ch2] [rtsp source] ready
2022/05/25 14:28:52 INF [HLS] [muxer ch2] is converting into HLS
2022/05/25 14:28:52 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:28:56 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/1653460134.ts
2022/05/25 14:28:58 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:28:58 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:28:59 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:29:00 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:29:01 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:29:02 INF [path ch2] [rtsp source] stopped
2022/05/25 14:29:02 INF [HLS] [muxer ch2] destroyed (terminated)
2022/05/25 14:29:03 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:29:03 INF [HLS] [muxer ch2] created
2022/05/25 14:29:03 INF [path ch2] [rtsp source] started
2022/05/25 14:29:03 INF [path ch2] [rtsp source] ready
2022/05/25 14:29:03 INF [HLS] [muxer ch2] is converting into HLS
2022/05/25 14:29:07 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:29:09 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:29:09 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/1653460145.ts
2022/05/25 14:29:12 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/stream.m3u8
2022/05/25 14:29:12 INF [HLS] [conn 127.0.0.1:14599] GET /ch2/1653460149.ts
2022/05/25 14:29:13 INF [path ch2] [rtsp source] stopped
2022/05/25 14:29:13 INF [HLS] [muxer ch2] destroyed (terminated)

rtmp logs:

2022/05/25 14:33:52 INF rtsp-simple-server v0.18.4-1-g23ac079
2022/05/25 14:33:52 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2022/05/25 14:33:52 INF [RTMP] listener opened on :1935
2022/05/25 14:33:52 INF [HLS] listener opened on :8888
2022/05/25 14:34:22 INF [RTMP] [conn 127.0.0.1:1259] opened
2022/05/25 14:34:22 INF [path ch2] [rtsp source] started
2022/05/25 14:34:22 INF [path ch2] [rtsp source] ready
2022/05/25 14:34:22 INF [RTMP] [conn 127.0.0.1:1259] is reading from path 'ch2'
2022/05/25 14:34:32 INF [path ch2] [rtsp source] stopped
2022/05/25 14:34:32 INF [RTMP] [conn 127.0.0.1:1259] closed (terminated)
0ip commented 2 years ago

With a config like that, even with version v0.18.4-1-g23ac079, I still have the problem

paths:
  foo:
    source: rtsp://bar
    sourceOnDemand: yes
    sourceProtocol: "tcp"
aler9 commented 2 years ago

added in v0.18.5. Please open another issue if the problem persists.

NickSurin commented 2 years ago

You fixed for sourceOnDemand but for runOnDemand problem still exists.

aler9 commented 2 years ago

@NickSurin please open another issue and provide a precise way to replicate.