Last active
November 23, 2016 12:45
-
-
Save jovandeginste/f4dca1b7a06861ac34560e1c49f0cea7 to your computer and use it in GitHub Desktop.
converts a playlist.m3u8 webstream (containing chunks) to an mp4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
url="$1" | |
output="$2" | |
base=$(dirname "$url") | |
chunklist=$(curl -s "$url" | grep "^chunklist") | |
if [[ -f "$output" ]] | |
then | |
echo "File '$output' already exists; skipping." >&2 | |
exit | |
fi | |
for chunk in $chunklist | |
do | |
files=$(curl -s "$base/$chunk" | grep "^media" | grep -v '_ao_') | |
total=$(echo $files | wc -w) | |
now=0 | |
for file in $files | |
do | |
now=$((now+1)) | |
echo "Fetching $file ($now/$total)" >&2 | |
curl -s "$base/$file" | |
done | |
done | ffmpeg -n -i - -f mp4 "${output}.part" | |
mv -v "${output}.part" "${output}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment