Is there a way to search and then download from YouTube, with the situation that I only need to download the audio only, not the video.

10 Answers 10


First, install youtube-dl:

sudo apt-get install youtube-dl

Then download and convert the YouTube video

youtube-dl http://www.youtube.com/watch?v=dQw4w9WgXcQ -x

The -x converts it to audio.

Further audio options:

-x, --extract-audio              convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)
--audio-format FORMAT            "best", "aac", "vorbis", "mp3", "m4a", "opus", or "wav"; best by default
--audio-quality QUALITY          ffmpeg/avconv audio quality specification, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default 5)

Home Page:

  • +1 for answer but youtube-dl has no ability to search in youtube
    – Maythux
    Feb 15, 2014 at 7:15

You can search and download using youtube-dl. All you need to do is provide the search terms in the link, like so:

 youtube-dl -f bestaudio 'https://www.youtube.com/results?search_sort=video_view_count&filters=video&search_query="SEARCH TERM(S) HERE"'  

Since that brings up all videos with the search term either in the title or the description (or the comments?), you can further restrict downloading to only those videos with the search term (or any other term) in the title, then use --match-title like so:

 youtube-dl -f bestaudio --match-title "<regex or caseless sub-string>" 'https://www.youtube.com/results?search_sort=video_view_count&filters=video&search_query="SEARCH TERM(S) HERE"'  

You can also reject videos using --reject-title in the same way as --match-title, or use both in conjunction.

Incidentally, I just tried those searches and something is buggy in youtube's search facility. If you remove the "search_sort=video_view_count" part of the string, it gives many more results, some of which have none of the terms in them, although the videos were related, so be careful.

The above answer is not really complete. Youtube-dl has a built-in search facility for Google, Youtube, and Yahoo. For those three, you can use the commands 'gvsearchX:TERMS', 'ytsearchX:TERMS', and 'yvsearchX:TERMS' respectively, and replace the 'X' with the number of results you want (and replace the 'TERMS' with your search terms, obviously).


An alternative to youtube-dl has been described here: New Command Line YouTube Player And Downloader With Local Playlists Support: mps-youtube. The article is quite detailed but just to quote what seems relevant to your question:

mps-youtube is a new tool which, besides being able to download YouTube videos (either the whole video or just the audio), can also search and play YouTube videos and create local playlists, all from the command line.
By default, this is basically a YouTube audio player (and downloader), but you can enable (external) video playback from its options.

This program needs the presence of python-pip and mplayer (both of which installable by apt-get). Then, run sudo pip install mps-youtube and you're done.

You can read more about mps-youtube here.


  • this program downloads just the audio if you so wish and hence you save on bandwidth: instead of downloading a video and then extracting the audio at your end, you download just the audio.
  • if you don't wish to install all the recommends suggested by sudo apt-get install python-pip use sudo apt-get install --no-install-recommends python-pip. That works just as well (for the specific purpose of installing mps-youtube).
  • sudo apt-get install --no-install-recommends python3-pip as per initial link
    – cipricus
    Mar 23, 2021 at 7:55

It's possible. After installing youtube-dl (sudo apt-get install youtube-dl) Simply

youtube-dl --format bestaudio <link>

And it will save an .m4a file with the video's title.


  • Not necessarily an .m4a, however. It will be whatever format is the best audio quality.
    – pak
    Sep 14, 2017 at 19:31

To fetch all downloadable formats:

youtube-dl -F <URL> 

To download mp3 directly:

youtube-dl --extract-audio --audio-format mp3 <URL>
  • This doesn't download mp3 directly. It downloads the best video format, and extracts the audio, then post-processes the audio from the video, converting into mp3 (which is almost certainly not the audio that is embedded in the video). So it degrades the audio quality.
    – pak
    Sep 14, 2017 at 19:29

For me, what did the trick is:

  1. Downloading latest version of youtube-dl as specified in their README (otherwise it may crash; at least the version that my Ubuntu pulled, did).
  2. Use the --extract-audio flag, as @blade19899 recommended.
  3. Use also the --format bestaudio flag, as @Xenoth recommended.


./youtube-dl --extract-audio --format bestaudio https://www.youtube.com/watch?v=3LZugKYOx80

I'm using Ubuntu 16.04, and Audacity 2.1.2, activate the Firefox add-on "download helper". While Youtube video is playing, click on the three coloured ball symbol at upper RH side of Firefox display, select the form of download (eg fast) and the system tells you when the video is downloaded. From downloads, select "show in folder" then R-click and select "open with Audacity", the audio file is then on screen. To extract as, say mp3, select "export audio", change the file extension to "mp3", select your destination, eg "music", and away you go. Before export, you can tune the audio using Audacity to remove unwanted preliminary speaking or crowd clapping.


You can use third-party tools like 4K YouTube to MP3. This allows you to extract only audio from a video clip. https://www.4kdownload.com/products/product-youtubetomp3

They even have a short tutorial on how to do so https://www.4kdownload.com/howto/howto-convert-video-to-mp3



enter image description here

Right-click > Audio only > Download (or just play)

I prefer it as Appimage.


As the other answers have noted, youtube-dl is perfect for this.. to download with highest quality then you can use the command:

youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 https://youtube.com/watch?v=bT-HDjub20o

If you can't or don't want to use youtube-dl, then there are several websites that can do this for you.. I personally recommend https://youtube-dlmp3.com

  • This will convert whatever the embedded audio is to mp3, thereby degrading audio quality. If you want the actual best audio quality, then you would specify -f bestaudio and leave it at that.
    – pak
    Sep 14, 2017 at 19:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .