Add gst-raiplay-download.sh
authorAntonio Ospite <ao2@ao2.it>
Fri, 2 Dec 2016 11:51:58 +0000 (12:51 +0100)
committerAntonio Ospite <ao2@ao2.it>
Fri, 2 Dec 2016 11:51:58 +0000 (12:51 +0100)
shell/gst-raiplay-download.sh [new file with mode: 0755]

diff --git a/shell/gst-raiplay-download.sh b/shell/gst-raiplay-download.sh
new file mode 100755 (executable)
index 0000000..4fc86d8
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# example pipeline to download HSL streams from raiplay.it
+
+set -e
+
+[ "x$1" = "x" -o "x$2" = x ] && { echo "usage: $(basename $0) <source_m3u8_url> <output_file>" 1>&2; exit 1; }
+
+SOURCE_URL="$1"
+OUTPUT_FILE="$2"
+
+# use a fixed and high value for connection-speed to download the best quality video
+gst-launch-1.0 \
+  \
+  mp4mux name=mp4 fragment-duration=10 ! \
+  filesink location="$OUTPUT_FILE" \
+  \
+  "$SOURCE_URL" ! \
+  hlsdemux connection-speed=4294967 ! \
+  tsdemux name=ts \
+  \
+  ts.video_0_0100 ! h264parse ! queue ! \
+  mp4.video_00 \
+  \
+  ts.audio_0_0101 ! decodebin ! audioconvert ! lamemp3enc ! queue ! \
+  mp4.audio_00
+
+# NOTE: the audio re-encoding is necessary because aacparse lacks some
+# functionality, see: https://bugzilla.gnome.org/show_bug.cgi?id=723551