Created
December 15, 2019 11:21
-
-
Save TONYHOKAN/a02d0b3019c96760c3c242b331cea1ec to your computer and use it in GitHub Desktop.
This file contains 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 | |
# what is m3u8: | |
# https://notfalse.net/63/m3u8-intro | |
# https://www.cnblogs.com/f-ck-need-u/p/9033988.html | |
# how to download m3u8 video: | |
# you have to install ffmpeg | |
# 1 in chrome go f12 network tab, find xxx.m3u8 file | |
# 2 download that file all content to local, generally, that m3u8 file url all pointing to local, we need change to url path | |
# 2a some video maybe encrypted with, in m3u8 you may see: #EXT-X-KEY:METHOD=AES-128,URI= | |
# 2b then should also download that key in local, or you need change the path, URI= to full url so that ffmpeg can download | |
# 3 also you will see many XXX.ts in that file, that is segment of whole video, you need to change change that to full path, i.e 720p_000.ts to https://vpx16.myself-bbs.com/45311/002/720p_000.ts so that ffmpeg can download | |
# 4 execute command: ffmpeg -protocol_whitelist "file,http,https,tcp,tls,crypto" -allowed_extensions ALL -i m3u8 -c copy target.mp4, -i is the m3u8 file just download, -c is path and name to save file | |
# 4a if ffmpeg need download to many XXX.ts and hang, you can download key and XXX.ts to local | |
# 4b use below script, ./download_ts.sh 0 100 https://vpx16.myself-bbs.com/45311/002/720p_, to download all file to local, you can also download encryption key in local | |
# 4c then again run command 4 can compact all segment | |
start=$1 | |
end=$2 | |
url=$3 | |
for i in `seq $start $end` | |
do | |
number=0 | |
if [ "$i" -lt "10" ] | |
then | |
number="00$i" | |
elif [ "$i" -lt "100" ] | |
then | |
number="0$i" | |
else | |
number="$i" | |
fi | |
# echo $number | |
wget "$url/$number.ts" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment