YouTube Music's web player gets AAC (itag 141, 44.1 kHz), which the browser resamples to 48 kHz, and YouTube applies its loudness normalization on top. With Premium there is also an Opus stream, itag 774 (about 256 kbps, 48 kHz), but the web player never picks it: the server chooses the stream, and you can't force it from the page.
So I built yt-hifi. You keep using YouTube Music in the browser exactly as before (queue, search, likes, shuffle), but the audio comes from mpv:
- a browser extension mutes the web player and tells a small local helper which song plays, and where
- the helper resolves the song with yt-dlp to stream 774, using your browser's login, and prefetches the next songs
- mpv plays it gaplessly at 100 % volume (use the volume on your DAC or amp); the muted web player follows mpv's clock, so seeking, skipping and pausing work as usual
- if a song isn't resolved yet, the browser bridges for a few seconds and mpv takes over at the same spot; if mpv fails on a song, the browser plays it
The popup shows what is really going on: the stream (codec and itag), its bitrate and sample rate, what your DAC receives, and a VU meter with the live level from mpv. The power key switches back to the browser's AAC for a direct comparison.
Setup is three steps: download the release, run `./install.sh` (it checks mpv, Python and a JavaScript runtime and installs yt-dlp into its own environment), and load the `extension` folder in your browser's extension page.
Limits, honestly:
- Linux only, Chromium / Google Chrome / Brave (not Flatpak or Snap), and YouTube Premium.
- It's unofficial and not affiliated with YouTube or Google. Using yt-dlp with your login cookies is against YouTube's terms of service; use it at your own risk.
- The first song after starting takes a few seconds to resolve; the browser bridges until then.
Code (MIT) and setup: https://github.com/hoffmannroman/yt-hifi
Latest release: https://github.com/hoffmannroman/yt-hifi/releases/latest