Skip to content

Start typing. Errors match on their exact yt-dlp output.

to move, to open esc to close

Extract Audio with yt-dlp: MP3, M4A and Lossless Copies

Tested on yt-dlp 2026.07.28 Updated

Quick answer

Ripping to MP3 re-encodes audio that was already compressed once, so it is bigger and slightly worse than the original. Unless a specific device demands MP3, keep what YouTube already has:

no re-encoding, seconds instead of minutes
yt-dlp -x --audio-format m4a --embed-thumbnail --embed-metadata "URL"
MP3, when a device requires it
yt-dlp -x --audio-format mp3 --audio-quality 0 --embed-thumbnail --embed-metadata "URL"

Why m4a beats mp3 here

YouTube stores audio as AAC (in m4a) or Opus, both around 128 kbps. Those are already lossy. Converting to MP3 means decoding lossy audio and re-encoding it lossily — a second generation of loss, for a file two to three times the size.

Asking for 320 kbps does not recover anything. There is no additional detail in the source to capture; the bitrate just describes how much space is spent storing the same audio. The number is bigger, the file is bigger, the sound is not better.

FormatRe-encodes?Use when
m4aNoDefault. Plays on Apple devices, Android, everything modern
opusNoSmallest; not read by older hardware
bestNoWhatever the source is — fastest, least lossy
mp3YesCar stereos, DJ software, legacy hardware
flacYesNever, for this source — see below
wavYesFeeding another tool that wants uncompressed input

Keeping whatever is best

--audio-format best tells yt-dlp not to convert at all. Fastest, and lossless in the only sense available here:

bash
yt-dlp -x --audio-format best --embed-thumbnail --embed-metadata "URL"

You get .opus or .m4a depending on what the site served. If mixed extensions in one folder bother you, ask for m4a specifically — YouTube's AAC is m4a already, so nothing is re-encoded.

Metadata and cover art

Without these, you get a file called Some Track (Official Video) with no tags, which no music player will organise:

bash
yt-dlp -x --audio-format m4a \
  --embed-thumbnail \
  --embed-metadata \
  --convert-thumbnails jpg \
  -o "%(artist,uploader)s/%(track,title)s.%(ext)s" \
  "URL"

--convert-thumbnails jpg is there because YouTube serves WebP, and neither mp3 nor m4a will embed it — the symptom is ffmpeg exited with code 1 during postprocessing, which reads as a much bigger problem than it is.

Turning a title into real tags

Music uploads usually put the artist in the title: Artist - Track (Official Video). --parse-metadata splits that into fields a player understands:

bash
yt-dlp -x --audio-format m4a \
  --parse-metadata "%(title)s:%(artist)s - %(title)s" \
  --embed-metadata --embed-thumbnail \
  -o "%(artist)s/%(title)s.%(ext)s" \
  "URL"

For a YouTube Music album, the fields are usually already correct and this is unnecessary — check with --dump-json before adding rules that fight good metadata.

Albums and podcasts

an album, in order
yt-dlp -x --audio-format m4a \
  --embed-thumbnail --embed-metadata \
  -o "%(playlist)s/%(playlist_index)02d - %(title)s.%(ext)s" \
  "ALBUM_PLAYLIST_URL"
a podcast feed, new episodes only
yt-dlp -x --audio-format m4a \
  --download-archive podcast.txt \
  --embed-metadata --embed-chapters \
  -o "%(uploader)s/%(upload_date>%Y-%m-%d)s - %(title)s.%(ext)s" \
  "CHANNEL_URL"

--embed-chapters is worth having on podcasts specifically: it turns YouTube's chapter markers into seekable positions in the audio file.

Keeping the video too

By default -x deletes the source once extraction succeeds:

bash
yt-dlp -x --audio-format m4a --keep-video "URL"

Also useful as insurance while testing a postprocessing chain — if it fails, you still have the download and can retry without fetching it again.

A config for music

Worth keeping separate from your main config, and selecting per job:

~/.config/yt-dlp/music.conf
-x
--audio-format m4a
--audio-quality 0
--embed-thumbnail
--embed-metadata
--convert-thumbnails jpg
--no-playlist
-o %(artist,uploader)s/%(album,playlist)s/%(track,title)s.%(ext)s
-P ~/Music/yt-dlp
bash
yt-dlp --config-location ~/.config/yt-dlp/music.conf "URL"

If it fails

  • ffmpeg not found. Extraction is entirely ffmpeg's work — install it.
  • "Unknown encoder libmp3lame" on Linux. A minimal ffmpeg build. sudo apt install libavcodec-extra.
  • No cover art in the file. Add --convert-thumbnails jpg.
  • Tags missing in one player, present in another. Some players read only ID3v2.3. --postprocessor-args "-id3v2_version 3" writes the older revision.

Frequently asked

Is 320 kbps MP3 better than the original?
No. YouTube's audio is around 128 kbps Opus or AAC. Converting it to 320 kbps MP3 decodes lossy audio and re-encodes it lossily, producing a file three times larger that is very slightly worse. The number is bigger; the audio is not.
Then why would I ever use MP3?
Compatibility. Old car stereos, DJ software, some hi-fi hardware and a few phones only read MP3. That is a real reason and the only one — if your player handles m4a or opus, use those.
What does --audio-quality 0 mean?
Best, on a 0-to-10 VBR scale. It is also the default, so it only earns a place on the command line when you are setting something else. With --audio-format best it is ignored entirely, because nothing is re-encoded.
Why is there no cover art in my file?
Either --embed-thumbnail was omitted, or the thumbnail was WebP and the container refused it. --convert-thumbnails jpg fixes the second case.