Use mpv to open YouTube (and more) videos from your web browser [Firefox, Chrome]

mpv handler Is a protocol handler mpv Written in Rust, with a browser user script, allowing users to use mpv to open videos from YouTube, Twitch and Bilibili.

It works with Firefox and Chromium-based web browsers on Linux and Microsoft Windows without using any background services.

After setting up all the content, visit the video on one of the aforementioned websites, and a new button (in the lower left corner) will appear on the video page, allowing you to play the video using mpv, which is a free and open source media player.

From its settings, you can control the video quality, if you want to pass a cookie, this is useful for watching member videos.

Since mpv uses youtube-dl to play videos, and youtube-dl supports hundreds of websites, you can add support for other video sharing websites by editing the “play mpv” user script.

This feature is especially useful if your web browser does not support hardware accelerated video playback. In this case, playing videos in mpv format (with hardware acceleration enabled) should allow smoother playback of high-quality videos and lower CPU usage (thus reducing battery consumption). Using it also means that you will not receive 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 many options, such as Play MPV E.g. However, the difference from most alternatives is that mpv-handler can be used with Firefox and Chromium-based browsers and does not require a server.

Install mpv-handler on Linux

1. Download the latest From GitHub, extract the archive and copy mpv-handler arrive ~/.local/bin/ with mpv-handler.desktop arrive ~/.local/share/applications/ with config.toml arrive ~/.config/mpv-handler

On Arch Linux / Manjaro, you can install mpv-handler from the following location AUR .

For other Linux distributions, you can do all of this from the command line using the following commands:



unzip -d mpv-handler

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’s important to note that you need to have ~/.local/bin In your path.If not, please add PATH="$HOME/.local/bin:$PATH" arrive ~/.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 of most Linux distributions, so please install it from there.

Since the website frequently changes and breaks youtube-dl, if you installed youtube-dl from the Linux distribution repository, I recommend deleting it (unless it is constantly updated) and installing it using PIP:

                        python3 -m pip install --user --upgrade youtube-dl

Use the same command to upgrade youtube-dl.

3. Install the Violentmonkey or Tampermonkey user script manager plug-in for your web browser.

The “Play with mpv” user script does not support Greasemonkey 4.0+, so you need to install the Violentmonkey or Tampermonkey plug-in:

4. Install the “Play with mpv” user script.

visit “Play mpv” user script page And click the install button.

5. Register a new URL scheme handler with XDG.

You should now see a new button in the lower left corner of a supported website (e.g. YouTube) that allows the current video to be played in mpv format.

But this works out of the box for me. I have to register a new URL scheme handler with XDG to make it work, even though this is not mentioned in the mpv-handler documentation.

This can be done by using the following command:

                        xdg-mime default mpv-handler.desktop x-scheme-handler/mpv

That’s it. Open the video on YouTube and you should see a new floating button in the lower left corner of the website. Click it, and the web browser will ask you whether to allow the site to open mpv links:


Play mpv dialog Firefox mpv handler

Chromium-based web browser (I use the Brave browser in the screenshot below):

Play mpv based chrome dialog

After opening the link, the video should be opened with the mpv media player. Note that this will also open a new terminal window. You need to keep it open while watching the video. When you close mpv, the terminal window will also close automatically.

In addition, in both browser cases, you can check the box to always use mpv-handler to open mpv links.

For how to install this program for Microsoft Windows, see This page .

You may also like: mpv-based Haruna video player 0.6.0 adds MPRISv2 and YouTube playlist support


Related Posts