Extract an audio file from a video using youtube-dl

This commit is contained in:
Matt McWilliams 2021-05-09 10:57:40 -04:00
parent 66e3396bf2
commit 2787ae31e6
1 changed files with 29 additions and 0 deletions

29
stream/audio.sh Normal file
View File

@ -0,0 +1,29 @@
#!/bin/bash -e
#####################################################
#
# This script will download a video and extract the
# audio as an .mp3.
#
# Usage: bash stream/rtmp.sh <input video> <rtmp url>
#
#####################################################
URL="${1}"
if [ "${1}" == "" ]; then
echo "Please provide a URL to download"
exit 1
fi
if [ -d "${2}" ]; then
DIR="${2}"
else
echo "Please provide an output directory for your audio file"
exit 2
fi
youtube-dl -x \
--audio-format mp3 \
-o "${DIR}/%(title)s-%(id)s.%(ext)s" \
"${URL}"