Regarding setting up a fallback for multiple RTSP streams proxied through MediaMTX #3251
-
QuestionI've hit a snag with my MediaMTX setup while attempting to initiate a fallback stream using FFmpeg with the runOnInit directive. It appears that the environment variables $RTSP_PORT and $MTX_PATH aren't initialized when runOnInit triggers the command. My goal is to have MediaMTX manage RTSP streams and establish a fallback stream through FFmpeg that kicks in automatically upon MediaMTX startup. The aim is to seamlessly switch to the fallback stream if any of the primary streams encounter issues. Expected Behavior:
Here's a simplified version of my YAML configuration:
However, it seems that $RTSP_PORT and $MTX_PATH aren't available when runOnInit is triggered, resulting in errors. I've attempted using the runOnDemand directive as an alternative, but I'm uncertain if it's suitable for my scenario. Unfortunately, both runOnInit and runOnDemand configurations fail, causing MediaMTX to abort. I'd appreciate any guidance on ensuring that the environment variables are properly initialized when starting the fallback stream. Thanks for your assistance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Probably not the cleanest option and should probably be using MediaMTX built in "fallback:" just don't know how, so scripted my own version using Bash script FFMpeg and FFProbe, the way I figure it if it is on a cron for every 2-5 seconds it will do the trick just fine:
This then outputs this into the config.yml assuming in this particular instance none of the cameras are streaming so it has defaulted all the stream sources to the fallback:
I tested this streaming to VLC App and it works |
Beta Was this translation helpful? Give feedback.
Probably not the cleanest option and should probably be using MediaMTX built in "fallback:" just don't know how, so scripted my own version using Bash script FFMpeg and FFProbe, the way I figure it if it is on a cron for every 2-5 seconds it will do the trick just fine: