Make the rtsp server only "read" the stream being broadcast to it on demand (i.e if someone is trying to fetch the stream from the server) #275
Replies: 5 comments
-
Hello, this can be solved in a lot ot ways, these are the two that come in mind way 1Start a second instance of rtsp-simple-server on the Raspberry Pi with this configuration paths:
cam:
runOnInit: ffmpeg -f v4l2 -i /dev/video0 -maxrate 4M -b 2M -f rtsp rtsp://localhost:8554/cam Edit the configuration of the main instance running on the server in this way paths:
cam:
source: rtsp://raspberry-url/cam
sourceOnDemand: yes The setup is now this In this way, the stream will be pulled only when requested, saving bandwidth. way 2edit the configuration on the server in this way paths:
stream:
runOnDemand: /script.sh create a script with this content: #!/bin/sh
trap 'echo sending ssh command to the raspberry pi to stop the stream' INT
echo sending ssh command to the raspberry pi to start the stream
sleep 86400 and edit the two parts to do exactly what they are supposed to do :) |
Beta Was this translation helpful? Give feedback.
-
in my setup the rapsberry pi is behind a NAT so ways 1 and 2 aren't really an option. |
Beta Was this translation helpful? Give feedback.
-
@Mohamedemad4 no idea if it's works in this Szenario but you could try RabbitMQ. OnDemand command would be a shell script on the rtsp-simple server host that produces one message on start and another (different) one on trap INT. You would need to consume these on your RPI and act accordingly. |
Beta Was this translation helpful? Give feedback.
-
thanks for the suggestion @dlueth. what we ended up doing was quiet similar. Just using redis Pub/Sub instead. I thought since RTSP can be used for controlling remote media (from my understanding at least) then something like that should have been trivial to implement inside RTSP. I am closing this issue but, if anyone has any ideas to do this inside RTSP feel free to re-open. |
Beta Was this translation helpful? Give feedback.
-
RTSP can be used only for unidirectional communication from client to server, not the opposite - a MQTT-based solution is the best approach in this case. |
Beta Was this translation helpful? Give feedback.
-
Which version are you using?
v0.13.2
OS: Linux (Ubuntu 20.04)
Question
sourceOnDemand
work if rtsp-simple-server is deployed in server mode? and if not what's an alternative?Description
I have a raspberry pi streaming a webcam to an RTSP server running rtsp-simple-server with ffmpeg
ffmpeg -f v4l2 -i /dev/video0 -maxrate 4M -b 2M -f rtsp rtsp://user:[email protected]:8554/stream
sourceOnDemand
toyes
in all paths. but the server is sill receiving the same bandwidth weather somone is reading the rtsp stream or notAlso if i am going about this the wrong way. please do tell me how this can be achieved/where to look. Or if i can make a PR or something and contribute this functionality (idk a lot about rtsp if that wasn't obvious lol)
@aler9
Beta Was this translation helpful? Give feedback.
All reactions