I may or may not have become addicted to a particular video on YouTube, and I wanted to download the MP3 for offline use.
(Whether it’s allowed or not is up for debate, knowing copyright laws it probably depends per country.)
Luckily, I remember I featured a YouTube downloader once in cron.weekly issue #23 that I could use for this.
So, a couple of simple steps on Mac to download the MP3 from any YouTube video. All further commands assume the Brew package manager is installed on your Mac.
(Note: the original youtube-dl is no longer actively maintained. These days you want yt-dlp
, a drop-in fork that takes the exact same flags. The commands below have been updated to use it.)
$ brew install ffmpeg yt-dlp
To download and convert to MP3:
$ yt-dlp --extract-audio --audio-format mp3 --prefer-ffmpeg https://www.youtube.com/watch?v=3UOtF4J9wpo
[youtube] 3UOtF4J9wpo: Downloading webpage
[youtube] 3UOtF4J9wpo: Downloading video info webpage
[youtube] 3UOtF4J9wpo: Extracting video information
[youtube] 3UOtF4J9wpo: Downloading MPD manifest
[download] 100% of 58.05MiB
[ffmpeg] Destination: 3UOtF4J9wpo.mp3
Deleting original file 3UOtF4J9wpo.webm
And bingo, all that remains is the MP3!