From aba7738b4ca0cca4de7f7aa8fd5eed5769af9506 Mon Sep 17 00:00:00 2001 From: mmaster Date: Tue, 21 Sep 2021 21:40:02 +0200 Subject: [PATCH] updated code, external random video function --- view_birdcam.sh | 61 ++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) diff --git a/view_birdcam.sh b/view_birdcam.sh index 080a645..b231633 100755 --- a/view_birdcam.sh +++ b/view_birdcam.sh @@ -29,56 +29,35 @@ if [ -z "$1" ]; then exit 0 fi -cameralist="~/birdcam/conf/cameralist.txt" ### var +cameralist="~/birdcam/conf/cameralist.txt" ### var playerproc="vlc" ### var -playerparam="--no-osd" ### var +playerparam="--no-osd --play-and-exit" ### var streamurl="rtsp://$1:554/user=admin&password=&channel=1&stream=0.sdp?real_stream" ### var -folder="/home/pi/Video" ### var + +randomvideosh="/home/pi/birdcam/randomvideo.sh" ### var +randomvideoproc="randomvideo.sh" ### var + +if [ ! -z "$(pgrep $playerproc)" ]; then + pkill $playerproc +fi + +if [ ! -z "$(pgrep $randomvideoproc)" ]; then + pkill $randomvideoproc +fi if [ "$1" = "random" ]; then ### var - - playerstat="$(pgrep $playerproc)" - file="$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)" + $randomvideosh + exit 0 +fi -# echo "$file"; sleep 10 - - if [ -z "$playerproc" ]; then - $player_path $playerparam "$file" - - else - kill $playerstat - $player_path $playerparam "$file" - - fi - -elif [ "$1" = "birdcam1" ]; then ### var - - playerstat="$(pgrep $playerproc)" - - if [ -z "$playerproc" ]; then - $player_path $playerparam "$streamurl" - - else - kill $playerstat - $player_path $playerparam "$streamurl" - - fi +if [ "$1" = "birdcam1" ]; then ### var + $player_path $playerparam "$streamurl" elif [ "$1" = "birdcam2" ]; then ### var - - playerstat="$(pgrep $playerproc)" - - if [ -z "$playerproc" ]; then - $player_path $playerparam "$streamurl" - - else - kill $playerstat - $player_path $playerparam "$streamurl" - - fi + $player_path $playerparam "$streamurl" else - echo "Wrong camera! Avaiable cameras:" + echo "Wrong camera! Available cameras:" cat $cameralist fi \ No newline at end of file