MPV media player - improve Youtube and Twitch support with yt-dlp and Streamlink
mpv media player is an open source software to play video and audio files. It’s minimalistic and does not use any graphical interface except video output and simple controls, but it’s still pretty full-featured.
Today, I want to tell you how to make it slightly more useful by making it play videos from youtube and streams from services like twitch. For example, it can be used with conjunction with rss feeds for the sake of privacy or minimalism.
You can call me Laika, and this is my small text guide about my favorite media player. Please sit down, clean you task bar from any unnecessary clutter, and let us begin this tutorial.
Replace youtube-dl with yt-dlp Link to heading
As you should already know, you can play videos from internet resources in MPV, which for the most part uses youtube-DL for that purpose. Youtube-DL is an app to download videos from different websites, starting, of course, with youtube. Unfortunately, original youtube-DL is barely maintained as for today, so google already learned how to make it unusable by slowing down downloads if youtube finds them suspicious.
To fix this, you need to download yt-dlp, which is one of actively maintained replacements, and make mpv use it unstead:
-
For Windows users there is a very simple method. Download Windows executable from github releases, then rename it to youtube-dl.exe, and place it in mpv installation folder, replacing original youtube-dl file if it’s present.
-
On Linux or other Unix-like systems, you can use your default package manager and install it by looking up command in official installation guide. Or you can just download standalone linux package and place it somewhere you won’t delete it accidentally, and make it executable with
chmod +X yt-dlp
command.After that you should go to your home directory, then and go to .local/mpv/, and open or create mpv.conf file, paste this line there and save it.
script-opts=ytdl_hook-ytdl_path=/bin/yt-dlp
Also, if you used standalone linux package, you should replace folder path at the end of this config line to where you left the package.
After that you will be able to play youtube videos and Twitch streams with mpv <link to the video>
command or by opening mpv and gragging and dropping url into a window
Use Streamlink Link to heading
This part of the guide is reducant and can easily be skipped if you don’t plan to use these services, because Twitch and Youtube streams work with perfectly yt-dlp.
I want to thank @Joshix@uwu.social for correcting me in comments about that
Next part of this guide will be a lot more consistent between Windows and Linux, because it just requires separate command-line app, called Streamlink. It can be installed with installer or portable executable on Windows, has AppImage and packages for most popular package managers for Unix-like systems.
That said, you need to:
- Install Streamlink using suitable command from official guide (
sudo apt install streamlink
one on Ubuntu,sudo dnf install streamlink
on Fedora, or follow Windows guide on Windows, or Python/PIP one if you don’t have one for your distribution) - Copy link to stream webpage
- Use this command
streamlink --player=mpv <link to stream> best
(you may need to change--player=mpv
to--player=path/to/your/player
)
Video Walkthrough Link to heading
(video was original version of the guide in case of this guide)