Youtube-dl is a powerful command-line tool to help you download videos from various online services. If you are feeling its commands and switches are too hard to remember, below are a few youtube-dl recipes to help you. Or better yet, you can use one of the best youtube-dl GUIs which we've covered a while ago.
This article will focus on youtube-dl recipes that only download audio.
You can browse our youtube-dl recipes for merging audio and video to know more about its powerful abilities when use in conjunction with supported libraries.
1. Download only audio as mp3 with youtube-dl
If you want to download only the audio part and skip the video, here is your command :
youtube-dl -i --extract-audio --audio-format mp3 --audio-quality 0 https://www.youtube.com/watch?v=dQw4w9WgXcQ
--extract-audio tells youtube-dl to extract only the audio part, either by grabbing audio link separately or downloading the whole video and then extracting it using ffmpeg.
--audio-format mp3 is self-explanatory, we want to save the audio in mp3 format. You can replace mp3 with one of these : "best", "aac", "flac", "mp3", "m4a", "opus", "vorbis". If you don’t specify
audio-format, it will be default to “best”.
--audio-quality 0 means that youtube-dl always try to grab the best quality audio available for you. The value can be any integer from 0 (best) to 9 (worst) for VBR. If you want to save in a specific CBR birate, for example 128 kbps, just input
--audio-quality 128. By default, youtube-dl will use
--audio quality 5.
2. Extract audio from a playlist with youtube-dl
If you want to download all the audio from a playlist with youtube-dl, please type in the following command in the terminal :
youtube-dl --yes-playlist --extract-audio https://www.youtube.com/watch?v=PjyX5dnhaMw&list=PLovlAKbQVz6BX4g4zSCX7nGIa_CKEGlCl
--yes-playlist is the option which affirms youtube-dl that the URL points to a playlist.
You can also pass other options like the above recipe to suit your needs.
If the playlist that you want to download from has a large number of videos in it, you may want to log the downloaded videos so that you can later verify that all videos have been downloaded.
You may also want to avoid overwriting existing files.
youtube-dl --download-archive downloaded.txt --no-overwrites --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 https://www.youtube.com/playlist?list=UUCvVpbYRgYjMN7mG7qQN0Pg
--download-archive downloaded.txt will log files into a text file named
--no-overwrites is the option which tells youtube-dl not to overwrite files that existed in current directory