Paste the following into nano editor:#!/bin/bash
### BEGIN INIT INFO
# Provides: mplayer
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Displays camera feeds for monitoring
# Description:
### END INIT INFO
# Output mplayer to remote device if using ssh remotely
if [ -n "$SSH_TTY" ]; then
export DISPLAY=:0.0
fi
# Camera Feeds & Positions
top_left="screen -dmS top_left sh -c 'mplayer -noborder -x 640 -y 400 -geometry 0:0 rtsp://admin:admin@10.148.1.6:554/live1.264'";
top_right="screen -dmS top_right sh -c 'mplayer -noborder -x 640 -y 400 -geometry 640:0 rtsp://admin:admin@10.148.1.2:554'";
bottom_left="screen -dmS bottom_left sh -c 'mplayer -noborder -x 640 -y 400 -geometry 0:400 rtsp://admin:admin@10.148.1.4:554'";
bottom_right="screen -dmS bottom_right sh -c 'mplayer -noborder -x 640 -y 400 -geometry 640:400 rtsp://admin:admin@10.148.1.5:554'";
# Camera Feed Names
# (variable names from above, separated by a space)
camera_feeds=(top_left top_right bottom_left bottom_right)
#---- There should be no need to edit anything below this line ----
# Start displaying camera feeds
case "$1" in
start)
for i in "${camera_feeds[@]}"
do
eval eval '$'$i
done
echo "Camera Display Started"
;;
# Stop displaying camera feeds
stop)
sudo killall mplayer
echo "Camera Display Ended"
;;
# Restart any camera feeds that have died
repair)
for i in "${camera_feeds[@]}"
do
if !(sudo screen -list | grep -q $i)
then
eval eval '$'$i
echo "$i is now running"
fi
done
;;
*)
echo "Usage: /etc/init.d/cams {start|stop|repair}"
exit 1
;;
esac
Hey this works great!
Is there a way to control the volume on each stream once they are running. I would like to be able to mute and unmute each stream as needed?
I’m not sure but I would think it’s possible.
I should have looked a little harder before asking about volume.
Alt + Tab(ing) through each instance of mplayer gets me to what ever stream I want to control and then hitting ‘m’ on the keyboard mutes and unmutes it. Perfect for my use case.
Thanks again for the bash script!
Glad you were able to figure it out and thanks for sharing what you did to achieve this.