m3u8-fetch.sh 358 B

12345678910111213141516
  1. #!/bin/bash
  2. URI="${1}"
  3. FILE="${2}"
  4. if [ -z "${URI}" ] || [ -z "${FILE}" ] || [ -e "${FILE}" ]; then
  5. echo "Usage: ${0} URI output_file" 1>&2
  6. exit 1
  7. fi
  8. # Parse the playlist if needed
  9. if ! echo "${URI}" | grep -q -i '\.m3u8$'; then
  10. URI="`~/bin/video/m3u8-uri.sh "${URI}"`"
  11. fi
  12. # Fetch
  13. ffmpeg -i "${URI}" -bsf:a aac_adtstoasc -vcodec copy -c copy "${FILE}"