Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Start streaming sopcast address $1 with sp-sc-auth, then start VLC and monitor both processes.
- # Author: Chickamade <anh.chick@gmail.com>
- if ! test $# -eq 1
- then
- echo 'Usage: sopcast <sop://address>'
- exit 0
- fi
- if pgrep -f "sp-sc-auth $1"
- then
- echo sopcast: channel $1 already streaming, quitting >&2
- exit 0
- fi
- PORT=${1##*/}
- while [ $PORT -gt 60000 ]; do
- PORT=$((PORT-10000))
- # echo $PORT
- done
- echo sopcast: starting stream $1 on port $PORT >&2
- sp-sc-auth "$1" 3908 $PORT >/dev/null &
- SP_SC=`pgrep -f "sp-sc-auth $1 3908 $PORT"`
- if test -z $SP_SC
- then
- echo sopcast: stream $1 failed to start >&2
- exit 1
- fi
- sleep 3
- vlc http://localhost:$PORT/tv.asf >/dev/null 2>&1 &
- VLC=`pgrep -f "vlc http://localhost:$PORT/tv.asf"`
- if test -z $VLC
- then
- echo sopcast: VLC failed to start >&2
- kill -9 $SP_SC
- exit 1
- fi
- while true
- do
- if ! ps $SP_SC > /dev/null
- then
- echo sopcast: stream $1 died, killing VLC >&2
- kill $VLC
- exit 1
- fi
- if ! ps $VLC > /dev/null
- then
- echo sopcast: VLC not running, killing stream $1 >&2
- kill -9 $SP_SC
- exit 0
- fi
- sleep 10
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement