From 2787ae31e62acf178ba3cad78fae467ae0860649 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sun, 9 May 2021 10:57:40 -0400 Subject: [PATCH] Extract an audio file from a video using youtube-dl --- stream/audio.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 stream/audio.sh diff --git a/stream/audio.sh b/stream/audio.sh new file mode 100644 index 0000000..3cbb246 --- /dev/null +++ b/stream/audio.sh @@ -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 +# +##################################################### + +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}"