Plex Media Player and MPV with CUDA

The Plex Media Player is now part of the multimedia repository for Fedora 25+. I works as a standalone player and also as the main interface for an HTPC setup, where the “TV interface” starts as the main thing when you power up your system.

Plex Media Player uses MPV in the background, so any compilation option that was added to MPV, is now also part of Plex Media Player by using the same libraries that were already available in the multimedia repository.

If you are using Gnome Software, you will also find it in the software selection screens.

To install it on Fedora, just perform the following commands:

dnf -y install plex-media-player

You will then find it along with the other applications in your menu.

Normal desktop interface

To get to the normal desktop interface just look for the Plex Media Player icon in your menu. You will be greeted with the familiar Plex web interface, with the main difference being that the player is local through the MPV library.

Enabling Plex Media Player startup at boot

If you are planning to do an HTPC installation, and would like to have Plex Media Player starting instead of the login screen the moment you boot the device, execute the following commands as root:

dnf install plex-media-player-session
systemctl set-default plex-media-player
echo "allowed_users = anybody" >> /etc/X11/Xwrapper.config

The first command installs the required files (services, targets and PolicyKit overrides). The second command instructs the system to load by default the Plex Media Player target; that is X immediately followed by the player itself. The third command allows the system to start the X server as the Plex Media Player user, otherwise only users logged in through a console or root can start it.

You will be greeted with the TV interface just after boot:

If you want to go back to your normal installation (let’s say Gnome), then revert back the changes (again type the following commands as root):

systemctl set-default graphical
sed -i -e '/allowed_users = anybody/d' /etc/X11/Xwrapper.config
rpm -e plex-media-player-session

MPV with CUDA

This has been already available for a long time, but with FFmpeg 3.3, CUDA dynamic support loading is enabled also in MPV, so the hard dependency on the CUDA library is gone, and the binaries load the library dynamically:

$ strings /usr/bin/mpv | grep libcuda
libcuda.so.1
$ strings /usr/lib64/libmpv.so.1.25.0 | grep libcuda
libcuda.so.1

So assuming you have the Nvidia driver already installed with the appropriate CUDA part, you can then play a video with the following command line:

mpv --hwdec=cuda /path/to/video.file

And then check with nvidia-smi or with the Nvidia control panel if the video engine is being utilized:

If you want to enable that by default, just make sure your configuration file has something like this inside:

$ cat ~/.config/mpv/mpv.conf 
#hwdec=vdpau
#vo=vdpau
hwdec=cuda

5 thoughts to “Plex Media Player and MPV with CUDA”

  1. I heard that before Plex on fedora gave wasn’t compatible with SELinux and permissive mode should be used. Please how did you address this problem? Thanks
    PS: I also remind you that in some parts of the world for some reasons your repos cannot be used for bandwidth issues (sometimes below 50Kb/s or sometimes below 10Kb/s.. when then DNF shut itself)

  2. I’m using the Plex distributed version that just came out (1.7.6) with the DVR function. I also use the post processing function. With the new version, I’m getting these errors when running HandBrakeCLI:
    HandBrakeCLI: /usr/lib/plexmediaserver/libxml2.so.2: no version information available (required by HandBrakeCLI)
    HandBrakeCLI: /usr/lib/plexmediaserver/libxml2.so.2: no version information available (required by /lib64/libbluray.so.2)
    HandBrakeCLI: /usr/lib/plexmediaserver/libxml2.so.2: no version information available (required by /lib64/libbluray.so.2)
    HandBrakeCLI: /usr/lib/plexmediaserver/libz.so.1: version `ZLIB_1.2.9′ not found (required by /lib64/libpng16.so.16)

    Do you know how to get around this – or is this something the Plex folks have done and need to correct. Thanks!

Leave a Reply