Skip to content

Instantly share code, notes, and snippets.

Embed
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 https://www.youtube.com/playlist?list=UUCvVpbYRgYjMN7mG7qQN0Pg

# 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 https://www.youtube.com/playlist?list=UUCvVpbYRgYjMN7mG7qQN0Pg

# 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
@kaotisk-hund
Copy link

kaotisk-hund commented Mar 16, 2019

How to do the same thing with code? I have trouble extracting audio from the videos.

@page-work
Copy link

page-work commented May 13, 2019

HI guys! Is there a config file for youtube-dl?!

@miguelalcantar
Copy link

miguelalcantar commented May 15, 2019

@myns23
Copy link

myns23 commented Aug 28, 2019

Thank you so match its work for my playlist.. :)

@dagolinuxoid
Copy link

dagolinuxoid commented Nov 1, 2019

thx

@Mihoid
Copy link

Mihoid commented Feb 5, 2020

Grazie mille!

@GenericEric
Copy link

GenericEric commented Dec 16, 2020

Great stuff! Added this to my aliases in aliasrc.
yt="youtube-dl --add-metadata -i"
yta="youtube-dl -i --extract-audio --audio-format-mp3 --audio-auality 0" \

@tdlmatias
Copy link

tdlmatias commented Dec 21, 2020

Hi there, I have used very recently youtube-dl to extract a audio as mp3 - obs you need to have ffmpeg for this to work properly.
--> youtube-dl -x --embed-thumbnail --audio-format mp3 https://www.youtube.com/watch?v=VIDEOID

@NawalJAhmed
Copy link

NawalJAhmed commented Jun 5, 2021

thank you, simple and useful

@rcortezk9
Copy link

rcortezk9 commented Jul 21, 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?

@tdlmatias
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**

@t1u1
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.

@neiesc
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