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
11.95k stars 1.5k forks source link

How can I reduce network data usage when no one watch stream thread ? #139

Closed ToanJunifer closed 3 years ago

ToanJunifer commented 3 years ago

Which version are you using?

v0.9.15

Which operating system are you using?

Ubuntu 16.04.7 LTS

Question

Assume that: I have a device which pushes stream video to rtsp://IP:PORT/path. But in some cases, no one access on this rtsp link to view. But my device is still stream video and consumes network data. It's very wasted. How can I solve it ?

ToanJunifer commented 3 years ago

I find that rtspclientsink(I'm using it to stream video to your rtsp-simple-server) have a property called "do-rtsp-keep-alive". Did it work with your rtsp-simple-server ? If it's working, how can I use it? Thank you so much!

aler9 commented 3 years ago

Hello, the server can be configured to start a GStreamer pipeline when someone requests a path, and to shut it down if all clients disconnect:

paths:
  ondemand:
    runOnDemand: gst-launch-1.0 -v ... rtspclientsink location=rtsp://localhost:8554/mystream
    runOnDemandRestart: yes

If the pipeline can't be launched from the server side, an alternative consists in launch two instances of rtsp-simple-server, one on the device, and the other one on the server; you make the device publish to the first instance, and configure the second one to receive the first one, but only when someone requests it:

paths:
  proxied:
    source: rtsp://first-instance

The property do-rtsp-keep-alive has a completely different purpose.

ToanJunifer commented 3 years ago

Great. I can understand your feature. May you explain to me about property do-rtsp-keep-alive? I very want to compare and upgrade my knowledge. I think that do-rtsp-keep-alive keep a connection between rtspclient and rtspserver by low consumption data. If someone request on the path, rtspclient will transfer sufficient data to rtspsrver. Did I think right?