Skip to content

Instantly share code, notes, and snippets.

@chriskempson
Created October 25, 2018 07:23
Show Gist options
  • Save chriskempson/b2a3b9f5a8d39c5e41203aecc04982a8 to your computer and use it in GitHub Desktop.
Save chriskempson/b2a3b9f5a8d39c5e41203aecc04982a8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
title=$(echo $@ | grep -Po '(?<=copy ).+?(?=.ts)')
m3u8_url=$(echo $@ | grep -Po '(?<=-i ).+?\.m3u8')
if [ -z "$title" ] || [ -z "$m3u8_url" ]; then
echo "Please enter a valid ffmpeg command from http://kmake.net/gyaommsurl"
return
fi
echo "\nDownloading:\n$title\n\nFrom:\n$m3u8_url\n"
livestreamer --hls-segment-threads 10 --hls-timeout 300 --hls-segment-timeout 60 --hls-segment-attempts 10 "hls://$m3u8_url" best -o "$title.ts"
ffmpeg -i "$title.ts" -c copy -bsf:a aac_adtstoasc "$title.mp4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment