Skip to content

Instantly share code, notes, and snippets.

@thermatk
Created December 27, 2017 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thermatk/ca4a8091fc2b03788e7b9ec2552865bc to your computer and use it in GitHub Desktop.
Save thermatk/ca4a8091fc2b03788e7b9ec2552865bc to your computer and use it in GitHub Desktop.
HLS videos download
#!/bin/bash
url="$1"
filen="$2"
base=$(dirname "$url")
mkdir tmpwip
cd tmpwip
wget -O index.m3u8 $url
cp index.m3u8 files.txt
sed -i -e '/#EXT/d' files.txt
while read ts; do
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0 --continue $base/$ts
done <files.txt
ffmpeg -y -v warning -loglevel debug -i index.m3u8 -vcodec copy -c copy -f mpegts out.ts
ffmpeg -i out.ts -acodec copy -vcodec copy out.mp4
cp out.mp4 ../$filen.mp4
cd ..
rm -rf tmpwip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment