For those who still don’t have a Raspberry Pi 4 and are using older Raspberry Pis with the legacy graphics driver enabled and who would like to have a hardware accelerated mpv in the Raspbian Buster distribution you might find my recipe for a successful compile useful.
I have managed to get mpv working in Buster with my Pi 3B
using the legacy graphics driver. I compiled Mpv against the pre-installed ffmpeg in the Buster repository (which is a special Raspberry version compiled with mmal enabled). It should also be emphasized these instructions only apply to Raspbian Buster with the legacy graphics driver enabled on Raspberry Pi’s prior to Pi 4.
In order to get a succesful compilation of mpv-with mmal hardware acceleration it is necessarary to update the Raspberry Pi firmware before beginning the compilation by using:
sudo rpi-update (see caution)
Of course you should be aware and warned that there are many cautions from authoritative sources on the Raspbian website that firmware updates should not be taken lightly as it may cause malfunctions in your distribution. I personally have not experienced any problems with my distribution however. You may wish to refer to the following official Raspbian documentation “Updating the kernel”:
https://www.raspberrypi.org/documentati ... pdating.md
which also gives you the command to restore your firmware to the latest stable firmware should you experience problems i.e.:
sudo apt-get install --reinstall raspberrypi-bootloader raspberrypi-kernel..
After updating the firmware I Installed the following packages from the Raspbian Buster repository
via Synaptic graphical package manager which also automatically installs their associated dependencies:
I then downloaded the latest mpv:
to my home directory extracted it and opened the extracted folder in terminal. (It compiles fairly quickly.).I then input the following commands into terminal:
./waf configure --prefix=/usr
./waf build -j4
sudo checkinstall ./waf install
After the compilation completes you can of course delete the extracted folder but don’t forget to save your compiled deb file in safe storage in case you wish to use it again.
In order to get mpv working properly in raspberry pi. It is necessary to configure it properly by means of a configuration file – mpv.conf normally located in the folder:
Although Mpv’s reference manual specifies that video out for Rasperry pi is specified as vo=gpu , I found this didn’t work. Rather I specified video out as the supposedly deprecated vo=rpi.
The contents of my mpv.conf (which work very well) are as follows:
( note- to get full screen video toggle the “f” key.. Of course if you wish to display full screen as soon as it opens you could insert fs=yes into configuration)
The entry :
instructs mpv when the keyboard toggle “f” is used to toggle back and forth between a full screen and a small overlay pseudo-window if you will, that takes up 5% of the display and that starts at 1075 pixels from the right and 550 pixels down from the top and on my my television screen with a native resolution of 1360x768
This places a small but crystal clear video ( rendered as overlay rather than an x11 window) just up from the bottom right hand corner where it can be monitored and listened to without interfering too much with the rest of the screen and then toggled back and forth to fullscreen by using the keyboard command “ f ” . Obviously this
“hack “could be varied to suit personal preferences. Another “hack “ I experimented with was to instead put the following entry into the configuration file “ autofit=1% “ which allows you to toggle back and forth between full screen and a minuscule nearly invisible dot but still retain audio playback. These “hacks” allows you multitask, continue browsing, manipulate controls, change configurations etc. ( particularly when using mpv as the engine for the gui smplayer), while still monitoring the video in a small unobtrusive window. Various configurations options using autofit and geometry are described in mpv's online manual referenced above.
The entry: rpi-background=yes instructs mpv to paint a black background on the sides if a standard definition video does not take up the full width of the screen as this is more aesthetically pleasing and less distracting
The entry : ytdl-format=bestvideo[ext=mp4][width<=1920][height<=1080]+bestaudio[ext=m4a]/best[ext=mp4]/best
instructs mpv to play the best quality video returned by youtube-dl within the parameters specified.
Here is a succesful mpv.conf file I used for my 1080p television:
Since mmal video is rendered as an overlay it is important if you are in full screen mode to retain keyboard control or you are up the creek without a paddle so to speak. For mpv this means terminal must remain the active “focused” window .If you are in full screen and should lose focus on the terminal as the application “ on top “ you lose keyboard control. I notice this can happen if you should inadvertently though force of habit mouse click on the full screen display, when other windows are open. Focus can usually be quickly regained by pressing the alt-tab combo followed by fhe “f” toggle untill focus is regained. This is one of the few annoying drawbacks of mmal accelerated mpv/smplayer on the Pi. And it doesn’t happen often. It would be great if someone could offer advice on how to prevent this from happening in the first place. When watching a video with a web browser open I try to start the video when I am in a new tab.
So that your specifically compiled Raspberry Pi version of mpv does not get overwritten on distro update by the generic version of mpv currently in the Buster repository you should lock it and mark it as hold. The following article provides very useful information on how this can be effected:
https://www.linuxuprising.com/2018/10/h ... ng-in.html
I hope to post a follow up on experience with an mpv gui - smplayer which greatly enhances the experience of mpv especially on the older Raspberry pis which rely on an mmal overlay to achieve hardware accelerated video output.