There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

Tips on yt-dlp and YouTube audio quality?

Hi friends,

I’ve been using yt-dlp to download a few things off of YouTube Music, and I just wanted to ask a few questions about best practice. Right now, I’ve just been doing it this way:


<span style="color:#323232;">yt-dlp -f bestaudio -x
</span>

I’ve found that has usually downloaded .opus files (though, .m4a as of late—anyone know why this is?), but, I was wondering (for the sake of compatibility with different music players), do I lose anything by passing –recode mp3?

Also, about losing the .opus files, I got this output when I ran yt-dlp -F on a link:


<span style="color:#323232;">|ID |  EXT   RESOLUTION FPS CH |    FILESIZE  TBR PROTO | VCODEC         VBR ACODEC      ABR ASR MORE INFO
</span><span style="color:#323232;">--------------------------------------------------------------------------------------------------------------------------
</span><span style="color:#323232;">233 mp4   audio only        |                  m3u8  | audio only         unknown             Default
</span><span style="color:#323232;">234 mp4   audio only        |                  m3u8  | audio only         unknown             Default
</span><span style="color:#323232;">249 webm  audio only      2 |     1.30MiB  64k https | audio only         opus        64k 48k low, THROTTLED, webm_dash
</span><span style="color:#323232;">250 webm  audio only      2 |     1.64MiB  81k https | audio only         opus        81k 48k low, THROTTLED, webm_dash
</span><span style="color:#323232;">139 m4a   audio only      2 |  1019.36KiB  49k https | audio only         mp4a.40.5   49k 22k low, m4a_dash
</span><span style="color:#323232;">251 webm  audio only      2 |     3.03MiB 149k https | audio only         opus       149k 48k medium, THROTTLED, webm_dash
</span><span style="color:#323232;">140 m4a   audio only      2 |     2.64MiB 130k https | audio only         mp4a.40.2  130k 44k medium, m4a_dash
</span>

Any insights as to why I’m getting that throttling, and why it’s downloading m4a instead of opus? Is it even that much of a difference? Is there some option I can pass to yt-dlp to avoid this?

Any help is much appreciated!

Oha ,

Youtubes Audio quality is pretty terrible in general. Dont think you’ll lose too much

Supermariofan67 ,

Are you using the very latest version? YouTube changed their site again a few days ago and it broke yt-dlps ability to find all thr formats. Update yt-dlp and it should be back to normal. yt-dlp will prefer the opus when it is available by default.

Opus is much better than (YouTube’s) m4a. m4a is better than mp3 (which is an obsolete 30 year old format). YouTube doesn’t serve mp3 (so creating one means re-encoding), and re-encoding lossy formats always loses quality.

narc0tic_bird ,

It’s probably deciding what the best audio is by bitrate (file size) instead of codec.

Supermariofan67 ,

This would not be the default behavior of yt-dlp. Run yt-dlp -vF <video> to view the sort order used. Acodec should come before abr.

It used to be the behavior of the original youtube-dl, however.

ssm ,
@ssm@lemmy.sdf.org avatar

I don’t think opus can be stored in an mp3 container without reencoding. Opus can be stored in mkv, ogg (or opus, an alias of the ogg file format, unless that changed), mp4 (I think this may be experimental?), and webm, off the top of my head. Try using ffmpeg to copy to various formats: ffmpeg -i in.opus -c copy out.ext, replacing ext with whatever file format you need. -c copy will always be lossless.

You can also try reencoding as flac or another lossless audio codec, but this may balloon your file size.

cmnybo ,

Transcoding from one lossy codec to another just reduces the quality even more. You can transcode to wave or flac, but that will just increase the file size.

There won’t be much of a quality difference between opus and mp4. If the music was uploaded at 44.1K, the mp4 will be higher quality even though the bitrate is slightly lower since the opus would be resampled to 48K.

Supermariofan67 ,

Resampling does not lead to any perceptible quality loss, but encoding to aac with libavcodec’s encoder (as YouTube does) definitely will. At the very least, it cuts all frequencies above 15 kHz which are potentially audible. Opus does not, and 128k opus is usually considered transparent.

I can’t find it but somewhere there’s a very detailed explanation from Monty himself about it

deranger ,

deleted_by_author

  • Loading...
  • Comexs ,

    The reason for why I think it said usually considered transparent is because when you have a less busy track it sounds transparent and I think its from the perspective of the average end user.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines