088f1bacaa04447a706a92762cdce0af205f1df6
[experiments/gstreamer.git] / shell / gst-raiplay-download.sh
1 #!/bin/sh
2
3 # example pipeline to download HSL streams from raiplay.it
4
5 set -e
6
7 { [ "x$1" = "x" ] || [ "x$2" = x ]; } && { echo "usage: $(basename "$0") <source_m3u8_url> <output_file>" 1>&2; exit 1; }
8
9 SOURCE_URL="$1"
10 OUTPUT_FILE="$2"
11
12 # use a fixed and high value for connection-speed to download the best quality video
13 gst-launch-1.0 \
14   \
15   mp4mux name=mp4 fragment-duration=10 ! \
16   filesink location="$OUTPUT_FILE" \
17   \
18   "$SOURCE_URL" ! \
19   hlsdemux connection-speed=4294967 ! \
20   tsdemux name=ts \
21   \
22   ts.video_0_0100 ! h264parse ! queue ! \
23   mp4.video_00 \
24   \
25   ts.audio_0_0101 ! decodebin ! audioconvert ! lamemp3enc ! queue ! \
26   mp4.audio_00
27
28 # NOTE: the audio re-encoding is necessary because aacparse lacks some
29 # functionality, see: https://bugzilla.gnome.org/show_bug.cgi?id=723551