Skip to content

Instantly share code, notes, and snippets.

@niemasd
Last active May 28, 2023 01:59
Show Gist options
  • Save niemasd/1c5abb067808ef890a45c08fc4318069 to your computer and use it in GitHub Desktop.
Save niemasd/1c5abb067808ef890a45c08fc4318069 to your computer and use it in GitHub Desktop.
Download an M3U8 video stream and output it as an MKV using ffmpeg
#!/usr/bin/env bash
if [ "$#" -ne 2 ] ; then
echo "USAGE: $0 <m3u8_url> <out_file>"; exit
fi
base=$(echo "$1" | rev | cut -d'/' -f2- | rev)
curl -s $1 | grep -v "^#" | sed -e "s>^>$base/>" | xargs curl -s | ffmpeg -i pipe:0 -c:v copy -c:a copy $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment