DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far...

Welcome! This is a Q&A website for computer programmers and users alike, focused on helping fellow programmers and users. Read more

What are you stuck on? Ask a question and hopefully somebody will be able to help you out!
+1 vote

I use youtube-dl for downloading videos (from youtube) and then extract the music with ffmpeg. But big videos are slow to download and convert. Can I download the audio directly instead (such that it's faster to download and I don't have to convert)?

by

1 Answer

+2 votes
 
Best answer

You can use the -F flag to list all available formats for a video, including audio- or video-only, then the -f and the corresponding format code to download the file. Example:

$ youtube-dl -F [url]
format code  extension  resolution note
140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 4.58MiB

$ youtube-dl -f140 [url]
by
selected by
0

This works only for youtube or for any website?

+1

It doesn't work for all video sites, unfortunately. If only videos are available, you could reduce the download size somewhat in some cases by downloading the smallest resolution with the same audio quality and add the -x flag to extract the audio after download (and -k to keep the video file afterward instead of deleting).

+2

Adding to this answer: --format bestaudio --extract-audio --audio-format mp3 to download the best audio available in a specific format.

Contributions licensed under CC0
...