mpv handler is a protocol handler for mpv written in Rust which, accompanied by a browser user script, allows users to open videos from YouTube, Twitch and Bilibili with mpv.
It works with both Firefox and Chromium-based web browsers on Linux and Microsoft Windows without using a background service.
When everything is set up and a video is viewed on any of the above websites, a new button will appear on the video webpage (in the lower left corner) that will allow you to play that video using mpv, a free and open source Media player.
In the settings you can control the video quality and whether you want to pass cookies or not, useful for watching member videos.
Since mpv uses youtube-dl to play the videos and youtube-dl supports hundreds of websites, you can add support for other video sharing websites yourself by editing the “Play with mpv” user script.
This is especially useful if your web browser does not support hardware accelerated video playback. In this case, playing the video in mpv (with activated hardware acceleration) should result in smoother playback of high-quality videos and lower CPU utilization (and thus lower battery discharge). It also means you won’t get any in-video ads.
Related: How to Enable Hardware Accelerated Video Decoding in Google Chrome, Brave, Vivaldi, and Opera Browsers on Debian, Ubuntu, or Linux Mint
mpv-handler is nothing new. There are several alternatives, such as: Play with MPV for example. The difference to most alternatives, however, is that mpv-handler works with both Firefox and Chromium-based browsers and does not require a server.
Install mpv-handler on Linux
1. Download the latest version mpv-handler-linux-x64.zip from GitHub, extract the archive and copy it mpv-handler
to ~/.local/bin/
and mpv-handler.desktop
to ~/.local/share/applications/
and config.toml
to ~/.config/mpv-handler
On Arch Linux / Manjaro you can use mpv handler from. to install GOLD.
For other Linux distributions, you can do all of this from the command line using:
wget https://github.com/akiirui/mpv-handler/releases/latest/download/mpv-handler-linux-x64.zip
unzip -d mpv-handler mpv-handler-linux-x64.zip
mkdir ~/.local/bin/ #just in case
mkdir ~/.local/share/applications/ #just in case
cp mpv-handler/mpv-handler ~/.local/bin/
cp mpv-handler/mpv-handler.desktop ~/.local/share/applications/
mkdir ~/.config/mpv-handler
cp mpv-handler/config.toml ~/.config/mpv-handler/
It is important to note that you must have ~/.local/bin
in your PATH. If you haven’t already, add PATH="$HOME/.local/bin:$PATH"
to ~/.profile
(and restart the session).
2. Make sure that mpv and the latest youtube-dl are installed on your system.
mpv is available in the official repositories for most Linux distributions, so install it from there.
Since websites change frequently and youtube-dl breaks, I recommend removing youtube-dl if you installed it from your Linux distribution repositories (unless it is constantly updated) and installing it using PIP instead :
python3 -m pip install --user --upgrade youtube-dl
Use the same command to update youtube-dl.
3. Install Violentmonkey or Tampermonkey Userscript Manager Addon for your web browser.
Greasemonkey 4.0+ is not supported by the “Play with mpv” user script, so you need to install either Violentmonkey or Tampermonkey add-ons:
- Tamperaffe: Chromium-based web browsers (Google Chrome, Chromium, Brave, Opera, etc.) | Fire fox
- Violent monkey: Chromium-based web browsers (Google Chrome, Chromium, Brave, Opera, etc.) | Fire fox
4. Install the user script “Play with mpv”.
Visit the Userscript page “Playing with mpv” and click the Install button.
5. Register the new URL scheme handler with XDG.
You should now see a new button in the lower left corner of a supported website like YouTube that will allow playing the current video in mpv.
But that didn’t work out of the box for me. I had to register the new URL scheme handler with XDG for this to work. although this is not mentioned in the mpv handler documentation.
This can be done with the following command:
xdg-mime default mpv-handler.desktop x-scheme-handler/mpv
And that’s it. Open a video on YouTube and you should see a new floating button in the bottom left of the website. Click on that and the web browser should ask you if you want to allow the site to open mpv links:
Fire fox:
Chromium-based web browsers (I’m using the Brave browser in the screenshot below):
Once you open the link, the video should open with the MPV media player. Note that this will also open a new terminal window. You need to keep it open while you watch the video. When you close mpv, the terminal window will also automatically close.
Also, in both browser cases, you can check the box to always use mpv-handler to open mpv links.
Installation information for Microsoft Windows can be found at this page.
You might also like: mpv-based Haruna Video Player 0.6.0 adds support for MPRISv2 and YouTube playlists