From 57d63db034ec8ad55070985f7d83319350cc31a3 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Fri, 22 May 2009 10:50:20 +0300 Subject: [PATCH] Fixed setting parameters when protocol changes (Thanks to Peter Holik for reporting this one). Updated example scripts to use ffmpeg's direct UDP output and added a new "image.sh" script (Thanks to Peter Holik). --- HISTORY | 4 +++ iptv/image.sh | 84 +++++++++++++++++++++++++++++++++++++++++++ iptv/internetradio.sh | 2 +- iptv/linein.sh | 2 +- iptv/webcam.sh | 2 +- streamer.c | 9 ++--- 6 files changed, 96 insertions(+), 7 deletions(-) create mode 100755 iptv/image.sh diff --git a/HISTORY b/HISTORY index 38246d4..ae0c8e5 100644 --- a/HISTORY +++ b/HISTORY @@ -104,3 +104,7 @@ VDR Plugin 'iptv' Revision History 2009-xx-xx: Version 0.3.0 - Added iptvstream-notrap.sh script. +- Fixed setting parameters when protocol changes + (Thanks to Peter Holik for reporting this one). +- Updated example scripts to use ffmpeg's direct UDP output + and added a new "image.sh" script (Thanks to Peter Holik). diff --git a/iptv/image.sh b/iptv/image.sh new file mode 100755 index 0000000..1d2d038 --- /dev/null +++ b/iptv/image.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +set -e + +# image.sh is used by the VDR iptv plugin to transcode images from +# a web server to provide a video stream. +# +# The script originates from Peter Holik +# +# Example channels.conf entries: +# Energy;IPTV:50:IPTV|S0P0|EXT|png.sh|1:P:0:256:257:0:0:3:0:0:0 +# Temperature;IPTV:60:IPTV|S0P0|EXT|png.sh|2:P:0:256:257:0:0:3:0:0:0 +# Temperature Week;IPTV:70:IPTV|S0P0|EXT|png.sh|3:P:0:256:257:0:0:3:0:0:0 +# Server Temperature;IPTV:80:IPTV|S0P0|EXT|png.sh|4:P:0:256:257:0:0:3:0:0:0 +# Server Temperature Week;IPTV:90:IPTV|S0P0|EXT|png.sh|5:P:0:256:257:0:0:3:0:0:0 +# Traffic;IPTV:100:IPTV|S0P0|EXT|png.sh|6:P:0:256:257:0:0:3:0:0:0 +# +# webcam.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 + +# Channels.conf parameter +case ${1} in + 1) + URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=energy;type=electricity" + ;; + 2) + URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=temp;type=temperature;type_instance=Outdoor" + ;; + 3) + URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=temp;type=temperature;type_instance=Outdoor;begin=-604800" + ;; + 4) + URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=temp;type=temperature;type_instance=Server" + ;; + 5) + URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=temp;type=temperature;type_instance=Server;begin=-604800" + ;; + 6) + URL="http://proxy/cgi-bin/bin/graph.cgi?hostname=proxy;plugin=interface;type=if_octets;type_instance=ppp0" + ;; + *) + URL="" # Default URL - TODO get dummy picture + ;; +esac + +# Iptv plugin listens this port +PORT=${2} + +# Stream temporary files +IMAGE=/tmp/image.png +LOG=/dev/null + +{ +# Using wget because ffmpeg cannot handle http/1.1 "Transfer-Encoding: chunked" +wget -q -O "${IMAGE}" "${URL}" + +# Build stream from audiodump with cycle image as video +# PID 0x100/256 = Video 0x101/257 = Audio +exec ffmpeg -v 10 \ + -analyzeduration 0 \ + -loop_input \ + -i "${IMAGE}" \ + -f mpegts -r 25 -vcodec mpeg2video -b 4000k -s 664x540 -padleft 20 -padright 20 -padtop 16 -padbottom 20 \ + -an \ + "udp://127.0.0.1:${PORT}?pkt_size=16356" +} > ${LOG} 2>&1 diff --git a/iptv/internetradio.sh b/iptv/internetradio.sh index e53b308..2fed9ee 100755 --- a/iptv/internetradio.sh +++ b/iptv/internetradio.sh @@ -61,7 +61,7 @@ ffmpeg -v -1 \ -i "${FIFO}" \ -title "${TITLE}" \ -f mpegts -acodec mp2 -ac 2 -ab 96k -ar 48000 \ - - | nc -u 127.0.0.1 ${PORT} + "udp://127.0.0.1:${PORT}?pkt_size=16356" rm -f "${FIFO}" } > ${LOG} 2>&1 diff --git a/iptv/linein.sh b/iptv/linein.sh index 268540d..35ea5a9 100755 --- a/iptv/linein.sh +++ b/iptv/linein.sh @@ -50,5 +50,5 @@ ffmpeg -v -1 \ -i - \ -title "${TITLE}" \ -f mpegts -acodec mp2 -ac 2 -ab 128k -ar 48000 \ - - | nc -nu 127.0.0.1 ${PORT} + "udp://127.0.0.1:${PORT}?pkt_size=16356" } > ${LOG} 2>&1 diff --git a/iptv/webcam.sh b/iptv/webcam.sh index 49cfd9e..797ea72 100755 --- a/iptv/webcam.sh +++ b/iptv/webcam.sh @@ -63,7 +63,7 @@ ffmpeg -v -1 \ -title "${TITLE}" \ -f mpegts -intra -r 24 -vcodec mpeg2video -b 500k -s 352x288 \ -acodec mp2 -ac 2 -ab 96k -ar 48000 \ - - | nc -u 127.0.0.1 ${PORT} + "udp://127.0.0.1:${PORT}?pkt_size=16356" rm -f "${FIFO}" } > ${LOG} 2>&1 diff --git a/streamer.c b/streamer.c index a556b31..3ad9db7 100644 --- a/streamer.c +++ b/streamer.c @@ -89,16 +89,17 @@ bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Ind { debug("cIptvStreamer::Set(): %s:%d\n", Location, Parameter); if (!isempty(Location)) { - // Update protocol; Close the existing one if changed + // Update protocol and set location and parameter; Close the existing one if changed if (protocol != Protocol) { if (protocol) protocol->Close(); protocol = Protocol; - if (protocol) + if (protocol) { + protocol->Set(Location, Parameter, Index); protocol->Open(); + } } - // Set protocol location and parameter - if (protocol) + else if (protocol) protocol->Set(Location, Parameter, Index); } return true;