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).
This commit is contained in:
Rolf Ahrenberg 2009-05-22 10:50:20 +03:00
parent 2484c3bdd6
commit 57d63db034
6 changed files with 96 additions and 7 deletions

View File

@ -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).

84
iptv/image.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;