MPV is the best way to view media on Linux by a long shot. You can also do a few things you would not expect. MPV can do some crazy magic tricks with how script friendly it really is. You can use several languages to accomplish this. You can watch movies with senselessness, as in you could watch a trilogy by selecting the file they reside in. With a super minimal KISS style UI. You can use all kinds of key binds and more. MPV was built in C, so you get full native speeds and support on most operating systems. When first learning about MPV a few months back, there was some doubt that it could do as well as or better than VLC. One thing that is confirm-able is that MPV is very versatile compared to VLC.
We will go over how to install MPV on a few linux distributions, we don’t want to leave anyone out. Next we will show you a few commands that you can throw at MPV just using bash. Next we will share a set of my scripts that I use personally when using MPV. Now we will show you the official GitHub for a collection of MPV scripts in a few languages. Finally, we will go over what you can engineer using MPV, making perfect for Linux users. We are here for the choice. Let’s get right into it.
sudo pacman -S mpv
sudo apt install mpv
Now that we have MPV installed, we can go ahead and start it. The regular way to start it would be to just select it when opening media when you click on a file to watch.
In my workflow music is essential. If I can keep audio around, it helps to focus me. There are a few things that MPV can do. Not just watch movies or listen to music. You can also use it to stream from sites like Odysee. Once upon a time YouTube would let you. Now they slow you down until it’s unwatchable. So MPV cannot stream anything that youtube-dl cannot stream as it is a dependence for that functionality. Youtube-dl source code can be found here. It is really great, it inspired all kinds of scripts and GUI to use it as well. Now let’s take a look at these scripts and see what you think.
#!/bin/bash gnome-terminal -- sh ~/.bash/bin/mpv-launch.sh
You can see here that we are just calling the next script in gnome-terminal. This script is great if you like key bindings to open programs. Otherwise, you can ignore it if you don’t need to open a terminal like this. To use it just replace the terminal with what you like to use. You can also make your personal bash bin location wherever you like. It is just an easy location for me to store my scripts. The main takeaway is that you organize your scripts in a way that you can find them. To make a script executable use this command.
sudo chmod +x filename
All you need to do is replace “filename” with the script name of your choice. Now let’s move on to a more interesting script.
#!/bin/bash read -p "Make a selection, play a [V]ideo, [M]usic, or [U]RL: " c case $c in V) echo "Video files loading..." sh ~/.bash/bin/mpv-play-media-file.sh ;; M) echo "Audio files loading..." sh ~/.bash/bin/mpv-play-music-file.sh ;; U) echo "URL loading..." sh ~/.bash/bin/mpv-play-url.sh ;; *) echo "Sorry, invalid selection, goodbye." ;; esac
Now you can see this script gives you choice for a media file, music or URL. So, the top line is what is read to you. Then, you just type a capital V for video, M for music or U for URL. The c is used to pass your choice variable. You can name the variable how you wish. Notice that the naming convention matches the files we will be opening with the next scripts. It is just good file housekeeping.
Video is the name of the game when it comes to MPV. You should really like the interface. It is super minimal. With all the regular controls, play, pause, timeline selector, CC, and maximize minimize. Now let’s see how easy it is to play a media file using a script.
#!/bin/bash cd ~/Videos ls read -p "What video would you like to watch? " v mpv --fs "$v" sh ~/.bash/bin/mpv-launch.sh
This script takes you to your video directory first. Then it lists the contents of the directory. I would advise you to put all of your shows in individual directories. This is so you can just copy and paste them into the selection in to play the contents. So, you watch Harry Potter all in a row non-stop if you type in or copy in this file. Otherwise, you can just type or copy in a single selection as well. Then the variable is passed using v. MPV will then open the file in full-screen mode using the —fs option. The last thing that will happen is you will be brought back to the original choice menu, in a new process.
Now a URL media player is not the first thing that comes to mind when you talk about most media players. MPV has got this covered. You will want to stick to Odysee or other streaming sites that do not care like GOGO Anime. It really depends on you if you like this feature or not. It’s great for watching stuff for research that you don’t want to influence your viewer profile. This does not always work with just any link, so feel free to play around.
#!/bin/bash read -p "Play-URL: " v mpv --fs "$v" sh ~/.bash/bin/mpv-launch.sh
You can see this script is super simple. It asks for a URL, then uses v as a variable to add the URL of your choosing. This will happen in full-screen same as before. One difference is that you can see the cache loading in the timeline selector bar as a thin line. This can help you troubleshoot if video is downloading slow for streaming. So, you know if the site you choose is working right. Next we will end up in the original choice menu like before.
Now for some music. This one actually has a few choice menus to help you make your music choices. The script will play a directory like a play list. So make sure to put your music in their respective play list directories. As we will need to add this to this script. Don’t worry, Bash is fun.
#!/bin/bash read -p "Make Playlist selection, [W]ork, [P]lay, [M]etal, [T]echno, [M]iscellaneous : " c case $c in A) echo "Work play list loading..." mpv --playlist=/home/username/Music/Work ;; B) echo "Play play list loading..." mpv --playlist=/home/username/Music/Play ;; L) echo "Metal play list loading..." mpv --playlist=/home/username/Music/Metal ;; T) echo "Techno play list loading..." mpv --playlist=/home/username/Music/Techno ;; M) echo "Miscellaneous play list loading..." mpv --playlist=/home/username/Music/Misc ;; *) echo "Sorry, invalid selection, goodbye." ;; esac sh ~/.bash/bin/mpv-launch.sh
You can see that you can script out the operations and play just about anything you want. The best part is you can use other languages to code MPV up.
You can go ahead and check out a few different scripts on Github that will make it possible to do all kinds of things with MPV from video shorts editing to full on terminal anime players. Let’s go take a look! You can find one of the MPV scripts repositories here.
You can see they use Lua to script in this repository but you can find many more on Github. Perhaps even a language that you already know. Now we will look at a masterpiece of sorts. If you like anime this will be a bonus. The point is, you can really go crazy with building your own scripts. Maybe even re-purpose this one for another site you wish to use rather than GOGO Anime. You can find the source code here.
Now you can see this is a bash script that runs an anime command line interface. It is pretty cool to be able to run so many things using just MPV. One thing you can’t say is that MPV is restrictive. You can really play media in several ways. You can just click a file if you wish to play it in MPV, or you can unlock MPV and really go nuts. Don’t forget to check it out on Android. It works pretty well. It keeps cartoons playing for my daughters on car rides without the need to stop and select new media. Just play the whole directory like a play list. Try out MPV today, we don’t think you will regret it. Thanks for reading.