#!/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 #killall -9 ffmpeg.streamdev 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=192 fr=25 resx=720 resy=480 fifo=/tmp/streamsvideo${PARAMETER}.fifo { 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 echo "Getting new URL">>$LOG URL="/dev/video0" echo $PLX $URL >>$LOG echo "Change Channel to $PARAMETER on Cable Box" >>$LOG /usr/local/bin/6200ch -v ${PARAMETER} >>$LOG sleep 5s if [ -z "${URL}" ]; then logger "$0: error: URL not defined!" exit 1 fi if [ -z "${URL}" ]; then logger "$0: error: URL not defined!" exit 1 fi MYPID=$$ echo "Streamsvideo.sh PID is $MYPID" >>$LOG # Create transcoding options echo "Streamdev Plugin $PARAMETER $URL" >>$LOG # Capture VLC pid for further management in IPTV plugin #mkfifo $fifo #mplayer $mplayeropts -nocache "$URL" -dumpstream -dumpfile $fifo >>${LOG} & #MPID=${!} ffmpeg.streamdev -v 1 \ -i $URL -debug 1\ -f mpegts -r $fr -vcodec ${VCODEC} -b ${VBITRATE}k -copyts -s 1280x720\ -acodec ${ACODEC} -ac 2 -ab ${ABITRATE}k -ar 48000 \ "udp://127.0.0.1:${PORT}?pkt_size=32712" & PID=${!} echo "pid of ffmpeg.streamdev $PID" >> $LOG echo $PID >/tmp/iptv-$MYPID #echo $MPID >>/tmp/iptv-$MYPID /etc/vdr/plugins/iptv/procchk ${MYPID} & trap 'echo Trap activated; kill -9 ${PID} 2>> $LOG ' KILL INT EXIT QUIT TERM # Waiting for the given PID to terminate wait ${PID} kill -9 $PID } >> ${LOG} 2>&1