2007-10-18 21:33:15 +02:00
|
|
|
#!/bin/sh
|
2007-11-24 16:14:52 +01:00
|
|
|
#
|
2008-06-20 21:34:18 +02:00
|
|
|
# iptvstream.sh can be used by the VDR iptv plugin to transcode external
|
2007-11-24 16:14:52 +01:00
|
|
|
# sources
|
|
|
|
#
|
2008-08-23 07:15:30 +02:00
|
|
|
# (C) 2007 Rolf Ahrenberg, Antti Seppälä
|
2007-11-24 16:14:52 +01:00
|
|
|
#
|
|
|
|
# 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.
|
2007-10-18 21:33:15 +02:00
|
|
|
|
2007-10-19 23:36:27 +02:00
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
logger "$0: error: Invalid parameter count '$#' $*"
|
2009-03-06 18:06:47 +01:00
|
|
|
exit 1
|
2007-10-19 23:36:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Channels.conf parameter
|
|
|
|
PARAMETER=${1}
|
|
|
|
|
|
|
|
# Iptv plugin listens this port
|
|
|
|
PORT=${2}
|
|
|
|
|
2008-09-01 13:28:05 +02:00
|
|
|
# Default settings for stream transcoding
|
|
|
|
VCODEC=mp2v
|
2007-10-20 01:08:24 +02:00
|
|
|
VBITRATE=2400
|
2008-09-01 13:28:05 +02:00
|
|
|
ACODEC=mpga
|
2007-10-20 01:08:24 +02:00
|
|
|
ABITRATE=320
|
|
|
|
|
2007-10-20 00:44:42 +02:00
|
|
|
# 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
|
2007-11-22 18:36:37 +01:00
|
|
|
case ${PARAMETER} in
|
2007-10-20 00:44:42 +02:00
|
|
|
1)
|
2009-03-06 18:06:47 +01:00
|
|
|
URL=""
|
|
|
|
WIDTH=720
|
|
|
|
HEIGHT=576
|
2010-07-02 21:25:55 +02:00
|
|
|
FPS=25
|
2009-03-06 18:06:47 +01:00
|
|
|
;;
|
2007-10-20 00:44:42 +02:00
|
|
|
2)
|
2009-03-06 18:06:47 +01:00
|
|
|
URL=""
|
|
|
|
;;
|
2007-10-20 00:44:42 +02:00
|
|
|
3)
|
2009-03-06 18:06:47 +01:00
|
|
|
URL=""
|
|
|
|
;;
|
2007-10-20 00:44:42 +02:00
|
|
|
*)
|
2009-03-06 18:06:47 +01:00
|
|
|
URL="" # Default URL
|
|
|
|
;;
|
2007-10-20 00:44:42 +02:00
|
|
|
esac
|
2007-10-18 21:33:15 +02:00
|
|
|
|
|
|
|
if [ -z "${URL}" ]; then
|
|
|
|
logger "$0: error: URL not defined!"
|
2009-03-06 18:06:47 +01:00
|
|
|
exit 1
|
2007-10-18 21:33:15 +02:00
|
|
|
fi
|
|
|
|
|
2008-09-01 13:28:05 +02:00
|
|
|
# Create transcoding options
|
|
|
|
TRANSCODE_OPTS="vcodec=${VCODEC},acodec=${ACODEC},vb=${VBITRATE},ab=${ABITRATE}"
|
|
|
|
if [ -n "${WIDTH}" -a -n "${HEIGHT}" ] ; then
|
|
|
|
TRANSCODE_OPTS="${TRANSCODE_OPTS},width=${WIDTH},height=${HEIGHT}"
|
|
|
|
fi
|
2010-07-02 21:25:55 +02:00
|
|
|
if [ -n "${FPS}" ] ; then
|
|
|
|
TRANSCODE_OPTS="${TRANSCODE_OPTS},fps=${FPS}"
|
|
|
|
fi
|
2008-09-01 13:28:05 +02:00
|
|
|
|
2007-10-20 00:44:42 +02:00
|
|
|
# Create unique pids for the stream
|
|
|
|
let VPID=${PARAMETER}+1
|
|
|
|
let APID=${PARAMETER}+2
|
|
|
|
let SPID=${PARAMETER}+3
|
|
|
|
|
2007-11-24 16:14:52 +01:00
|
|
|
# Capture VLC pid for further management in IPTV plugin
|
2008-09-01 13:28:05 +02:00
|
|
|
vlc "${URL}" --sout "#transcode{${TRANSCODE_OPTS}}:standard{access=udp,mux=ts{pid-video=${VPID},pid-audio=${APID},pid-spu=${SPID}},dst=127.0.0.1:${PORT}}" --intf dummy &
|
2007-11-22 18:25:20 +01:00
|
|
|
|
2007-11-22 18:36:00 +01:00
|
|
|
PID=${!}
|
2007-11-22 18:25:20 +01:00
|
|
|
|
|
|
|
trap 'kill -INT ${PID} 2> /dev/null' INT EXIT QUIT TERM
|
|
|
|
|
|
|
|
# Waiting for the given PID to terminate
|
2007-11-22 18:36:00 +01:00
|
|
|
wait ${PID}
|