68 lines
1.4 KiB
Bash
Executable File
68 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
player="cvlc" ### var
|
|
player_path="$(command -v $player)" ### var
|
|
player_package="vlc" ### var
|
|
|
|
if [ -z "$player_path" ]; then
|
|
echo "Missing $player, try to install it ..."
|
|
|
|
echo "Check internet connection ..."
|
|
pingserver="raspbian.raspberrypi.org"
|
|
if ! ping -q -c1 $pingserver>/dev/null; then
|
|
echo "No internet connection ..."
|
|
exit 0
|
|
fi
|
|
|
|
sudo apt-get update; sudo apt-get -y install $player_package
|
|
|
|
player_path="$(command -v $player)"
|
|
|
|
if [ -z "$player_path" ]; then
|
|
echo "Cannot install $player, exiting ..."
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: $0 [Name_of_Camera]"
|
|
exit 0
|
|
fi
|
|
|
|
cameralist="~/birdcam/conf/cameralist.txt" ### var
|
|
playerproc="vlc" ### var
|
|
playerparam="--no-osd" ### var
|
|
streamurl="rtsp://$1:554/user=admin&password=&channel=1&stream=0.sdp?real_stream" ### var
|
|
|
|
if [ "$1" = "birdcam1" ]; then ### var
|
|
|
|
playerstat="$(pgrep $playerproc)"
|
|
|
|
if [ -z "$playerproc" ]; then
|
|
$player_path $playerparam "$streamurl"
|
|
|
|
else
|
|
kill $playerstat
|
|
$player_path $playerparam "$streamurl"
|
|
|
|
fi
|
|
|
|
elif [ "$1" = "birdcam2" ]; then ### var
|
|
|
|
playerstat="$(pgrep $playerproc)"
|
|
|
|
if [ -z "$playerproc" ]; then
|
|
$player_path $playerparam "$streamurl"
|
|
|
|
else
|
|
kill $playerstat
|
|
$player_path $playerparam "$streamurl"
|
|
|
|
fi
|
|
|
|
else
|
|
echo "Wrong camera! Avaiable cameras:"
|
|
cat $cameralist
|
|
|
|
fi
|