Your channels.conf file looks like this:
BBC 1;IPTV:10:IPTV|S0P0|EXT|iplayer.sh|14:P:0:256:257:0:0:11:0:0:0
BBC 2;IPTV:20:IPTV|S0P0|EXT|iplayer.sh|25:P:0:256:257:0:0:2:0:0:0
/etc/vdr/plugins/iptv/iplayer.sh (has some code to bring up or down a VPN if you need it)
- Code: Select all
#!/bin/sh
#
# iptvstream.sh can be used by the VDR iptv plugin to transcode external
# sources
#
# (C) 2007 Rolf Ahrenberg, Antti Seppälä
#
# iptvstream.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
if [ $# -ne 2 ]; then
logger "$0: error: Invalid parameter count '$#' $*"
exit 1
fi
echo >/tmp/iptvstream
# Channels.conf parameter
PARAMETER=${1}
# Iptv plugin listens this port
PORT=${2}
# Default settings for stream transcoding
LOG=/tmp/iptvstream
VCODEC=mpeg2video
VBITRATE=2000
ACODEC=mp2
ABITRATE=320
fr=29
resx=720
resy=480
fifo=/tmp/iplayer${PARAMETER}.fifo
maps=
mplayeropts=
aspect=16:9
{
echo Script started $1 $2 >>/tmp/iptvstream
# There is a way to specify multiple URLs in the same script. The selection is
# then controlled by the extra parameter passed by IPTV plugin to the script
case ${PARAMETER} in
14)
#BBC 1
channel="80002"
;;
25)
#BBC 2
channel="80005"
;;
27)
#BBC NEWS
channel="80001"
;;
53)
#BBC 3
channel="80004"
;;
54)
#BBC 4
channel="80000"
;;
55)
#CBBC
channel="80006"
;;
56)
CBeebies
channel="80007"
;;
*)
URL="" # Default URL
;;
esac
# Create transcoding options
echo "iPlayer Plugin $PARAMETER $channel" >>$LOG
#Check for VPN
if [ `pidof pppd` ]; then
echo pppd already running >>$LOG
else
echo Bringing up VPN >>$LOG
echo Kill Vuze
sudo killall java
sudo pon WorldVPN
fi
sleep 2s
ERR=1
while [ $ERR ]
do
ERR=
rm -fr $fifo
mkfifo $fifo
get_iplayer $channel --stream --type=livetv --livetvmode=flashnormal1,flashstd1,flashstd2,flashhigh1,flashvhigh1,flashhd1 >>$fifo &
MPID=${!}
sleep 5s
ffmpeg.iplayer -v 0 \
-i $fifo -debug 0\
-aspect $aspect \
-f mpegts -r $fr -vcodec ${VCODEC} -b ${VBITRATE}k -er 3 -b 2000k -s ${resx}x${resy} -copyts -v sync ${fr}\
$maps -acodec ${ACODEC} -ac 2 -ab ${ABITRATE}k -ar 48000 -async 1\
"udp://127.0.0.1:${PORT}?pkt_size=16356" &
PID=${!}
MYPID=$$
echo "pid of ffmpeg.iplayer $PID get_iplayer $MPID this script $MYPID" >>${LOG}
echo $PID >/tmp/iptv-$MYPID
echo $MPID >/tmp/iptv-$MYPID
/etc/vdr/plugins/iptv/procchk ${MYPID} vpn &
trap 'echo Trap activated; kill -9 ${PID}; kill -9 ${MPID} 2>> $LOG ' INT EXIT QUIT TERM
# Waiting for the given PID to terminate
wait ${PID}
ffmpegerr=`tail /tmp/iptvstream | grep "Cannot get resampling context" | awk '{printf $1}'`
if [ $ffmpegerr ];then
ERR=1
echo "$ffmpegerr Restart" >>${LOG}
else
ERR=
echo "$ffmpegerr Stop" >>${LOG}
fi
done
} >> ${LOG} 2>&1
kill -9 $MPID
kill -9 $PID
if [ `pidof get_iplayer` ]; then
echo iPlayer still running, vpn left up >>$LOG
else
sudo poff WorldVPN
echo Dropped VPN >>$LOG
sleep 5s
echo Adding route >>#$LOG
sudo route add default gw 192.168.2.1 >>$LOG
fi
/etc/vdr/plugins/iptv/prochk
- Code: Select all
#!/bin/bash
PIDOFSCRIPT=$1
vpn=$2
echo $PIDOFSCRIPT
while ps -p $PIDOFSCRIPT >/dev/null
do
sleep 1
done
echo Killing ffmpeg
cat /tmp/iptv-$PIDOFSCRIPT | xargs kill -9
rm /tmp/iptv-$PIDOFSCRIPT
if [ $vpn ]; then
if [ `pidof get_iplayer` ]; then
echo iPlayer still running, vpn left up
else
sudo poff WorldVPN
echo Dropped VPN
sleep 5s
echo Adding route
sudo route add default gw 192.168.2.1
fi
fi
