Closed forabi closed 1 year ago
Look at runOnDemand. It's explained in the config file
Run on demand does not work with runOnReady
Even if it did, the compressed stream would be started when the raw stream is accessed. This is not efficient. I want the compressed stream to only start when it's actually requested and shut down when it's not used.
On Wed, Mar 15, 2023, 12:35 AM raypanggh @.***> wrote:
Look at runOnDemand. It's explained in the config file
— Reply to this email directly, view it on GitHub https://github.com/aler9/rtsp-simple-server/issues/1541#issuecomment-1469006641, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHXIGOZMYMJSPI2DJVDM43W4D6DNANCNFSM6AAAAAAVTTT6QM . You are receiving this because you authored the thread.Message ID: @.***>
Not following the requirement.
I don't see any reference to startOnReady, only runOnReady.
Why not use runOnDemand? Ffmpeg will only start when the stream is requested. And it will be shut down when there are no consumers.
Ffmpeg will start compressing the stream when the raw stream is requested. I don't want to compress the stream if the compressed version is not being used.
Can you share your config so I can understand the use case?
This is an example of one stream that I need a compressed version of. As you can see, runOnReady
is started when the uncompressed stream is ready. If I combine sourceOnDemand
with runOnReady
, the compressed stream won't start unless the raw stream is requested. That does not make sense. Also, we cannot control ffmpeg to only compress on demand because it's started from the raw stream, not from the compressed path.
paths:
all:
publishUser: <redacted>
publishPass: <redacted>
1/unicast/compressed:
readUser: <redacted>
readPass: <redacted>
1/unicast:
readUser: <redacted>
readPass: <redacted>
source: rtsp://<redacted>:<redacted>@<ip>:8554/unicast
sourceOnDemand: no
sourceProtocol: udp
runOnReady: ffmpeg -i rtsp://<redacted>:<redacted>@localhost:$RTSP_PORT/$RTSP_PATH -c:v h264_v4l2m2m -b:v 600k -max_muxing_queue_size 1024 -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH/compressed
runOnReadyRestart: yes
Could you not make 1/unicast simply an RTSP proxy for rtsp://root:redacted>@<ip:8554/unicast, and then have 1/unicast/compressed call ffmpeg via runOnDemand?
I'm imagining this:
1/unicast/compressed:
runOnDemand: ffmpeg -i rtsp://<redacted>:<redacted>@localhost:$RTSP_PORT/1/unicast -c:v h264_v4l2m2m -b:v 600k -max_muxing_queue_size 1024 -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
runOnDemandRestart: yes
1/unicast:
source: rtsp://root:<redacted>@<ip>:8554/unicast
sourceOnDemand: no # or yes if you don't want the bandwidth consumption if nobody is using the uncompressed source
sourceProtocol: udp
This way the 1/unicast (the uncompressed stream) is always available, and only if 1/unicast/compressed is requested does ffmpeg kick in.
Tried it, but it didn't work:
Mar 15 16:57:50 raspberrypi rtsp-simple-server[5540]: 2023/03/15 16:57:50 INF [RTSP] [conn 192.168.0.168:56752] closed (no one is publishing to path '3/unicast/compressed')
3/unicast/compressed:
readUser: <redacted>
readPass: <redacted>
runOnReady: ffmpeg -i rtsp://<redacted>:<redacted>@localhost:$RTSP_PORT/3/unicast -c:v h264_v4l2m2m -b:v 600k -max_muxing_queue_size 1024 -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
runOnReadyRestart: yes
3/unicast:
readUser: <redacted>
readPass: <redacted>
source: rtsp://<redacted>:<redacted>@<ip>:8554/unicast
sourceOnDemand: yes
sourceProtocol: udp
Am I doing something wrong?
Hmm, it looks alright.
Try sourceOnDemand: no.
I suspect that 3/unicast isn't working because nothing is requesting it. As a result, 3/unicast/compressed won't work, as that relies on 3/unicast to be running.
Also you want runOnDemand, not runOnReady. runOnReady will leave you with the compressed stream running all the time.
If this doesn't work, I'll have a play with such a setup on my side and see if I can get it working.
Oh also you'll probably need to specify the credentials for publishing to 3/unicast/compressed, if you've got publishUser/publishPass configured.
-f rtsp rtsp://<publishUser>:<publishPass>@localhost:$RTSP_PORT/$RTSP_PATH
Try turning off all your authentication temporarily to eliminate that from the problem.
It works with your suggestions (but I also had to change ffmpeg params to the same ones in the README as mine were causing an empty stream)
This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.
Describe the feature
Description The README has instructions on how to do a compressed stream via runOnReady. I assume this means ffmpeg will unconditionally run whether there are consumers for the compressed stream or not. This starts to slowdown my Pi 4 with just two stream (I have a bunch of other stuff running, of course).
My question/request is: can I start and kill the compressed stream based on whether it's being used or not?