Skip to content

Instantly share code, notes, and snippets.

@ilovefood2
Forked from patrickgill/m3u8download.sh
Last active July 4, 2019 04:19
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 ilovefood2/f2a0e5e15070a52cd905e47e374ce4af to your computer and use it in GitHub Desktop.
Save ilovefood2/f2a0e5e15070a52cd905e47e374ce4af to your computer and use it in GitHub Desktop.
download m3u8 ts segments, then decode, join, and remux them! (HTTP Live Streaming TS files)
# download
wget http://xxx.com/upload/20180419/79bf8642d29b9d51a5bebb8ddd0ea926/79bf8642d29b9d51a5bebb8ddd0ea926.m3u8
aria2c -x 4 -j 4 -Z -P http://xxx.com/upload/20180419/79bf8642d29b9d51a5bebb8ddd0ea926/79bf8642d29b9d51a5bebb8ddd0ea926[000-286].ts
# decode (example)
#openssl aes-128-cbc -d -K 15D0F46608409DA364E3F5D92BDE9F61 -iv 00000000000000000000000000000000 -nosalt -in G00000000.ts -out G00000000.d.ts
# join all ts files
cat *.ts > out.ts
# convert ts output file
# This will re-encode the video and stream copy the audio:
# ffmpeg -i input -c:v libx264 -c:a copy -bsf:a aac_adtstoasc output.mp4
ffmpeg -i out.ts -vcodec copy -acodec copy newfile.mp4
rm *.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment