2

I am setting up multiple rtsp streams on rpi2. The rpi will act like surveillance station. After some research I've managed to do that, here is my script below:

#!/bin/bash
screen -dmS camera1 sh -c 'omxplayer --win "0 37 960 577" "http://www.spruto.tv/get_file/1/38577f19393369cb2c5d785beb3c3ffc/80000/80730/80730.mp4?start=0"; exec bash'
screen -dmS camera2 sh -c 'omxplayer --win "960 37 1920 577" "http://www.spruto.tv/get_file/5/717a259eabde324b660eaf07d3b56c7f/110000/110197/110197.mp4?start=0"; exec bash'
screen -dmS camera3 sh -c 'omxplayer --win "0 577 960 1080" "http://www.spruto.tv/get_file/5/717a259eabde324b660eaf07d3b56c7f/110000/110197/110197.mp4?start=0"; exec bash'
screen -dmS camera4 sh -c 'omxplayer --win "960 577 1920 1080" "http://www.spruto.tv/get_file/1/38577f19393369cb2c5d785beb3c3ffc/80000/80730/80730.mp4?start=0"; exec bash'

The thing is when a stream got stuck due to latency or any other reasons, omxplayer quits.

I would like to add a loop to every line, which would basically check if the screen session exists, if not it would then start it.

Could anyone help me do that?

1
  • @alwi Hi. I see that you developed the project playstreamation. Can you please direct me on the right way to document the watchdog part ? I want to do the same thing for a MPEG2 http stream. I want to check if the stream is active (not by checking the pid) and if not do not kill the omxplayer. Just leave it hanging and retry to connect and reconnect stream. Thank you !
    – badcata
    Commented Mar 2, 2017 at 13:20

2 Answers 2

-1

You may check GitHub project: playstreamation it seems to be made exactly for what you need.

-2

Replace each screen command for a loop:

while true; do omxplayer ....;done

So each time an omxplayer quits, it gets restarted.

2
  • As is, this will produce an infinite loop.
    – Jacobm001
    Commented Aug 11, 2015 at 15:12
  • Isn't that the intent? It's not launching omxplayer in the background, so it will run in the foreground until it quits, then re-start. It's not overly sexy but it does look like it would work.
    – bobstro
    Commented Sep 17, 2017 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.