> ## Content Index
> Fetch the complete content index at: https://itsfoss.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Download Audio Only Using youtube-dl
- URL: https://itsfoss.com/youtube-dl-audio-only/
- Published: 2021-08-19T12:23:04.000Z
- Updated: 2024-06-16T11:37:40.000Z
- Description: You can use youtube-dl to download only audio files from the online videos. Here's how to download entire playlists in MP3 format.
- Author: Abhishek Prakash
- Tags: Tutorial

[youtube-dl](https://github.com/ytdl-org/youtube-dl?ref=itsfoss.com) is a versatile command line tool for downloading videos from YouTube and many other websites. I use it for making back up of my own YouTube videos.

By default, you [use youtube-dl for downloading videos](https://itsfoss.com/download-youtube-linux/). How about extracting only the audio with youtube-dl? That’s very simple actually. Let me show you the steps.

🚧

Downloading videos from websites could be against their policies. It’s up to you if you choose to download videos or audio.

## Install youtube-dl first

Please make sure that you have installed youtube-dl on your Linux distribution first.

Since 2021, the usual snap and default package manager installations of youtube-dl give a broken utility. So, you need to install the Nightly version of youtube-dl to make it work.

The Nightly release contains recent changes and fixes so that you can run it without any error. I will describe the easiest way to set it up. First go to the Nightly release GitHub page.

[Download youtube-dl Nightly Release](https://github.com/ytdl-org/ytdl-nightly/releases/?ref=itsfoss.com)

Here, you can get a python file, named `youtube-dl`. Just download it. Once downloaded, copy that file to `/usr/local/bin/`. For this, open a terminal where you downloaded the file and then run:

```bash
sudo cp youtube-dl /usr/local/bin/

```

Now, give the file execution permission using the `chmod` command.

```bash
sudo chmod a+rx /usr/local/bin/youtube-dl

```

You cannot just run `youtube-dl` now, because of issue with `python` naming. It uses `python` while in Ubuntu-based systems, it is `python3`.

![Python: No such file or directory error, when try to rrun youtube-dl initially](https://itsfoss.com/content/images/2024/05/youtube-dl-python-env-python-command-error.png)

Python: No such file or directory error

So, [you can create an alias](https://linuxhandbook.com/linux-alias-command/?ref=itsfoss.com) for youtube-dl in your `.bashrc`.

```bash
alias youtube-dl='python3 /usr/local/bin/youtube-dl'

```

That’s it. You have set up youtube-dl in your system.

📋

****Remember**  
In order to download audio using youtube-dl, you should have [FFMPEG installed on your system](https://itsfoss.com/ffmpeg/).

## Download only audio with youtube-dl

If you only want to download audio from a YouTube video, you can use the `-x` option with youtube-dl. This extract-audio option converts the video files to audio-only files.

```
youtube-dl -x video_URL

```

The file is saved in the same directory from where you ran the youtube-dl command.

Here’s an example where I downloaded the voice-over of our [Install Google Chrome on Ubuntu 24.04](https://www.youtube.com/watch?v=Cfo5BR2FGEQ&ref=itsfoss.com) video.

![Download only audio from a video using youtube-dl "-x" option](https://itsfoss.com/content/images/2024/05/download-audio-only-using-youtube-dl-basic.svg)

Download only audio from a video using youtube-dl

Did you notice the audio format? It is in .m4a format. You may specify the audio format to something of your choice.

Say you want to extract the audio in MP3 format. You can use it like this:

```
youtube-dl -x --audio-format mp3 video_URL

```

Here’s the same example I showed previously. You can see that it [uses ffmpeg to convert](https://itsfoss.com/ffmpeg/) the m4a file into MP3.

![Download audio in a format specified, instead of the default m4a](https://itsfoss.com/content/images/2024/05/download-audio-in-mp3-format.svg)

Download MP3 File

💡

By default, youtube-dl deletes the older file, if you downloaded it twice, even if it's in a different format. So, you can use the `-k` option to preserve the old file along with the new one.

## Download entire YouTube playlist in MP3 format

Yes, you can totally do that. The main thing is to get the URL of the playlist here. It is typically in the following format:

```
https://www.youtube.com/playlist?list=XXXXXXXXXXXXXXXXXXX

```

To get the URL of a playlist, click on its name when the playlist is being displayed in the right sidebar.

![Click on the title of the playlist, appears on the right side, while you play a video.](https://itsfoss.com/content/images/2024/05/click-on-the-heading-of-the-playlist.png)

Click on the title of the playlist

It will take you to the playlist page, and you can copy the URL here.

![Copy the URL of the playlist from the address bar of the browser](https://itsfoss.com/content/images/2024/05/select-and-copy-the-playlist-url.png)

Copy the URL of the playlist

Now that you have the playlist URL, you can use it to download the audio files in MP3 format in the following fashion:

```
youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" playlist_URL

```

That scary looking `-o "%(title)s.%(ext)s"` specifies the output file (with option -o) and instructs it to use the title of the video and the extension (MP3 in this case) for naming the audio files.

![Download audio from all the videos on a playlist](https://itsfoss.com/content/images/2024/05/downloading-youtube-playlist-audio.webp)

Download audio from all the videos on a playlist

I hope you find this quick tip helpful. Enjoy the audio files 😄