Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Download Audio from YouTube with youtube-dl

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

--audio-format mp3 - convert to mp3

--audio-quality 0 - the best audio quality

--yes-playlist - affirm that url points to a playlist

YT_URL - video url from youtube

# Download single entry
youtube-dl -i --extract-audio --audio-format mp3 --audio-quality 0 YT_URL

# Download playlist
youtube-dl -ict --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0

# Download playlist, --download-archive downloaded.txt add successfully downloaded files into downloaded.txt
youtube-dl --download-archive downloaded.txt --no-overwrites -ict --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 --socket-timeout 5

# Retry until success, no -i option
while ! youtube-dl --download-archive downloaded.txt --no-overwrites -ct --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 --socket-timeout 5 <YT_PlayList_URL>; do echo DISCONNECTED; sleep 5; done
Copy link

tdlmatias commented Jul 23, 2021

When using the following command I'm getting an error.

youtube-dl -i --extract-audio --audio-format mp3 --audio-quality 0 YT_URL (This happens with any YouTube URL I use)

ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.

How can ffprobe/avprobe and ffmpeg/avconv?

Hi @rcortezk9 have installed ffmpeg on your system ?? Try to install then run the command again.. If you in Linux/Ubuntu

-$ sudo apt-get install ffmpeg,

  • or $ snap install ffmpeg
  • or if you on Mac - do $ brew install ffmpeg

Bear in mind that you need to have Snap installed or Brew for it work**

Copy link

t1u1 commented Dec 31, 2021

What about -f bestaudio? That seems to download the audio only version for me. The format is opus in webm container, not mp3, but that's okay with me, as most players work with it. I can convert to mp3 later if required.

Copy link

neiesc commented Jun 15, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment