Skip to content
yt-dlp

YouTube to MP3 with yt-dlp

Build the yt-dlp command that turns a YouTube video into a tagged MP3 with cover art.

Getting a usable MP3

Extraction is a conversion, so ffmpeg is required — this is the reason the command fails on a fresh install. Best (VBR) is the right default: it gives the best size-to-quality ratio, and a higher fixed bitrate cannot add quality the source never had.

Cover art and metadata turn a folder of anonymous files into something a music player can organise. The naming template here puts the artist first, falling back to the uploader when no artist is tagged.

--audio-quality 0 is the setting people most often get wrong. It is not "zero quality" — it is the best variable-bitrate setting, roughly 245 kbps on average, and the scale runs the other way: 0 is best and 9 is worst. Variable bitrate spends more bits on the busy parts of a track and fewer on silence, which is why a VBR file usually sounds better than a constant-bitrate one of the same size. If you need a fixed rate for a device that insists on it, ask for it by name — --audio-quality 320K — rather than guessing at a number on the 0–9 scale.

The bigger question is whether to convert at all. YouTube serves audio as Opus or AAC, and neither is MP3, so asking for MP3 always means re-encoding: the file is decoded and compressed a second time, and some quality goes with it every time. If nothing you own demands the .mp3 extension specifically, choose "Best (no conversion)" instead. It is faster, it skips ffmpeg entirely, and the result is closer to the source than any MP3 of it can be. Convert when a car stereo, a DJ program or an old phone leaves you no choice.

For a whole playlist, turn playlists on and add an archive file. The archive records what has already been fetched, so running the same command next week picks up only what is new instead of starting over — and combined with "keep going after errors", one region-locked or deleted track stops taking the other two hundred down with it. Add the playlist index to the output template if the running order matters; without it your player will sort the folder alphabetically and the album will be in the wrong sequence.

Optional. Leave it empty and the command ends with URL for you to fill in.

Your command

yt-dlp -x --audio-format mp3 --audio-quality 0 --no-playlist --embed-thumbnail --embed-metadata -o '%(artist,uploader)s - %(title)s.%(ext)s' 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
Basics

Audio-only extracts the soundtrack and drops the video stream.

Audio

The file the audio is converted to.

VBR gives the best size-to-quality ratio; fixed bitrates are more predictable.

Playlists and channels

What to do when the URL belongs to both a video and a playlist.

Ranges and lists both work, for example 1-10,15 or -5::2 for every second item from the end.

Advanced options (1)

Records what has been downloaded so re-running skips it. The way to keep a channel in sync.

Metadata and artwork
Advanced options (3)
Files and folders

Field names go in %(...)s. Slashes create folders.

Advanced options (4)

Where files are written. Combine with the template above for subfolders.

Maximum file name length in characters.

Workarounds
Advanced options (3)

Deprecated in favour of --add-headers. Kept because plenty of older guides still use it.

Deprecated in favour of --add-headers.

Site-specific switches, for example youtube:player_client=web.

Reset

Frequently asked questions

What MP3 quality should I choose?
Best (VBR) for most cases — it gives the best size-to-quality ratio. 320 kbps is only worth it if something downstream insists on a fixed bitrate. Neither adds quality the source did not have.
Why does MP3 extraction fail?
Converting audio requires ffmpeg. Install it and check with ffmpeg -version.
VBR or a fixed bitrate?
VBR spends bits where they matter and is smaller at the same perceived quality. Use a fixed bitrate only when a device or piece of software demands one.
Can I convert a whole playlist to MP3?
Yes — audio output plus whole-playlist handling. Add an archive file so a re-run does not redo the conversions.