MPV Shim for Plex (Cast to MPV on Linux/Windows)

MPV Shim for Plex v1.7.16
Changes:

  • Add ability to idle while paused and stop player when idle.
  • Add --config option to use an alternate config folder. (You must change the port, uuid, and name if you run multiple copies at the same time.)
  • Fix crash with some locales on Thursdays.
  • Add support for input.conf.

Install on Windows: Download the Binary

Install on Linux (requires libmpv1 or mpv):

sudo pip3 install --upgrade plex-mpv-shim

Optional to enable the GUI:

sudo pip3 install pystray
sudo apt install python3-tk

MPV Shim for Plex v1.8.0
This version adds support for the new Plex skip intro feature. By default, the player will notify you that you can skip an intro, and seeking forward using the keyboard or the web/mobile app during the intro will skip the entire intro. You can also enable automatic skipping, which will skip intros without asking. You can configure these features via the preferences menu (access with c) or the config file.

Other Changes:

  • Make esc key exit fullscreen when no menu is open. (#16)
  • Allow changing built-in keyboard shortcuts. (#16)
  • Allow changing seek amount of arrow keys. (#17)
  • Upgrade Windows MPV version to: mpv-dev-x86_64-20200517-git-152b0e2

Install on Windows: Download the Binary

Install on Linux (requires libmpv1 or mpv):

sudo pip3 install --upgrade plex-mpv-shim

Optional to enable the GUI:

sudo pip3 install pystray
sudo apt install python3-tk

It will be nice to have arm version. I’ve tried to build p-m-s from AUR repo in manjaro arm for rpi4 with no success. But, thanks , I’m using it on my tablet.

The program itself also has a pip package. It will use whatever copy of libmpv1 or mpv the system happens to have. You could try that if the AUR package is failing to build.

I don’t maintain the AUR package, so you probably want to talk to the maintainer to have the package fixed if there are issues.

Sorry for the delay. I;m newbie in Linux but I can use cli. So, I was on gihub, download zip but I have no idea what pip mpackage means. I suppose that is python package. Can you point how to use plex-mov-shim like pip package. I’m using manjaro if matters.

pip is a packaging systems for applications written in Python. Assuming you have it installed, you should be able to install the package using sudo pip3 install plex-mpv-shim or sudo pip install plex-mpv-shim. If you don’t use sudo, then you need to run the command as root.

You’ll also need a copy of libmpv1 or mpv installed. If you want to install the version with a tray icon, use sudo pip3 install plex-mpv-shim pystray, and you’ll also need to ensure the tk package is installed.

Yes and Thank You.It’s working surprisingly good. I’ve played some 10 bit hevc and it’s playing well.Thank You again.

Running both the shim and the local connection userscript, I get this error as soon as I try to cast:

2020-07-06 09:39:56,066 [   DEBUG] client: HttpHandler::handle_request request to '/player/playback/playMedia?type=video&providerIdentifier=com.plexapp.plugins.library&containerKey=%2FplayQueues%2F5090%3Fown%3D1&key=%2Flibrary%2Fmetadata%2F38524&offset=9000&machineIdentifier=d35725984cb33a6c46d7debc7c1154b5a93d3f04&protocol=https&address=10-20-30-100.ee151462190845a8bc6517064a5284c2.plex.direct&port=32400&token=REDACTED&commandID=1&X-Plex-Product=Plex%20Web&X-Plex-Version=4.37.1&X-Plex-Client-Identifier=hlgq222gzdnvhyhcuba6wn2n&X-Plex-Platform=Chrome&X-Plex-Platform-Version=83.0&X-Plex-Sync-Version=2&X-Plex-Features=external-media%2Cindirect-media&X-Plex-Model=hosted&X-Plex-Device=Linux&X-Plex-Device-Name=Chrome&X-Plex-Device-Screen-Resolution=1706x1288%2C3440x1440&X-Plex-Token=REDACTED&X-Plex-Language=en&X-Plex-Target-Client-Identifier=544cef7b-a050-49f2-9b36-1026df36f514'
2020-07-06 09:39:56,066 [   DEBUG] utils: get_plex_url Created URL: https://10-20-30-100.ee151462190845a8bc6517064a5284c2.plex.direct:32400/library/metadata/38524?includeMarkers=1&X-Plex-Token=REDACTED&X-Plex-Version=2.0&X-Plex-Client-Identifier=f1386a6e-21bf-4c82-a94b-188e67adfde4&X-Plex-Provides=player&X-Plex-Device-Name=desktop-alex&X-Plex-Model=RaspberryPI&X-Plex-Device=RaspberryPI&X-Plex-Session-Identifier=d551e01e-62c6-4f84-ad2d-f8f2a6a97889&X-Plex-Product=Plex+MPV+Shim&X-Plex-Platform=Plex+Home+Theater&X-Plex-Client-Profile-Name=Plex+Home+Theater
2020-07-06 09:39:56,081 [   DEBUG] utils: get_plex_url Created URL: https://10-20-30-100.ee151462190845a8bc6517064a5284c2.plex.direct:32400/playQueues/5090?own=1?includeMarkers=1&X-Plex-Token=REDACTED&X-Plex-Version=2.0&X-Plex-Client-Identifier=f1386a6e-21bf-4c82-a94b-188e67adfde4&X-Plex-Provides=player&X-Plex-Device-Name=desktop-alex&X-Plex-Model=RaspberryPI&X-Plex-Device=RaspberryPI&X-Plex-Session-Identifier=d551e01e-62c6-4f84-ad2d-f8f2a6a97889&X-Plex-Product=Plex+MPV+Shim&X-Plex-Platform=Plex+Home+Theater&X-Plex-Client-Profile-Name=Plex+Home+Theater
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 39560)
Traceback (most recent call last):
  File "/usr/lib/python3.8/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.8/http/server.py", line 647, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/lib/python3.8/http/server.py", line 427, in handle
    self.handle_one_request()
  File "/usr/lib/python3.8/http/server.py", line 415, in handle_one_request
    method()
  File "/usr/local/lib/python3.8/dist-packages/plex_mpv_shim/client.py", line 197, in do_GET
    self.handle_request("GET")
  File "/usr/local/lib/python3.8/dist-packages/plex_mpv_shim/client.py", line 175, in handle_request
    getattr(self, handler)(path, query)
  File "/usr/local/lib/python3.8/dist-packages/plex_mpv_shim/client.py", line 309, in playMedia
    media = Media(url, play_queue=playQueue)
  File "/usr/local/lib/python3.8/dist-packages/plex_mpv_shim/media.py", line 477, in __init__
    self.upd_play_queue()
  File "/usr/local/lib/python3.8/dist-packages/plex_mpv_shim/media.py", line 514, in upd_play_queue
    self.play_queue_xml = XMLCollection(self.get_path(self.play_queue))
  File "/usr/local/lib/python3.8/dist-packages/plex_mpv_shim/media.py", line 448, in __init__
    self.tree       = et.parse(urllib.request.urlopen(get_plex_url(url)))
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
----------------------------------------

Any clues? Just installed this morning, compiled MPV from scratch.

What error messages do you get in the Plex server console? Are you running the latest version of the Plex Media Server (1.19.4.2935-79e214ead)?

No to question 2, an update and reboot fixed it. :+1:

How do I enable english audio AND english subtitles for the entire series?

You want to select the “Manual by Track Index” option, then you can select the desired tracks for all episodes. (This assumes all the episodes use the same track orderings.)

1 Like

MPV Shim for Plex v1.9.0
This release introduces two major features for those who like video enhancement!

Shader Packs

MPV is known for having some of the most effective upscaler plugins, but these are difficult to install and switch between. The shader pack system allows creation of a profile of shaders and MPV configurations, which can be easily switched between. The menu system even allows you to reconfigure these settings while video is playing, without having to get off the couch!

The shader presets include FSRCNNX and Anime4K, which are two of the most effective video upscalers. You can read more about the profiles and contribute changes over at the repository for the presets.

If you would like to customize or add your own presets, you can do so by enabling the shader_pack_custom option, which will copy the shader pack to your config folder and inhibit it from updating when you update MPV Shim.

SVP Integration

image

You can now change between SVP profiles from the built-in menu. No need to exit the media player and use a keyboard/mouse to change your motion interpolation settings. Unlike shader packs though, this requires configuration. Please see the README for details. This feature has been verified to work on Windows and Linux.

Other Fixes:

  • Prevent skipping videos when seeking too much.

Install on Windows: Download the Binary

Install on Linux (requires libmpv1 or mpv):

sudo pip3 install --upgrade plex-mpv-shim

Optional to enable the GUI:

sudo pip3 install pystray
sudo apt install python3-tk

Installed on my linux Manjaro through pamac manager but I don’t see an option to cast to it from my phone? I must be missing something?

You need to be running the plex-mpv-shim program on your computer. Your mobile device must be connected to the same network as your computer. Neither devices can be using a VPN. If your computer has a firewall, you must allow ports TCP 3000 and UDP 32410, 32412, 32413, and 32414.

Please let me know if this helps, or if you need additional assistance.

how can I tell if

is running?

I installed it but I only see mpv Media player installed under application.

Looks like mpv installed automatically when I installed plex-mpv-shim

How do I launch plex-mpv-shim since I do not see it listed?

You have to start plex-mpv-shim using the command line. You can create a launcher item for it manually if desired.

(plex-mpv-shim:31548): Gtk-WARNING **: 17:37:03.310: Theme parsing error: gtk.css:68:35: The style property GtkButton:child-displacement-x is deprecated and shouldn’t be used anymore. It will be removed in a future version

(plex-mpv-shim:31548): Gtk-WARNING **: 17:37:03.311: Theme parsing error: gtk.css:69:35: The style property GtkButton:child-displacement-y is deprecated and shouldn’t be used anymore. It will be removed in a future version

(plex-mpv-shim:31548): Gtk-WARNING **: 17:37:03.311: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn’t be used anymore. It will be removed in a future version
2020-08-28 17:37:03,882 [ WARNING] root: Cannot load GUI. Falling back to command line interface.
Traceback (most recent call last):
File “/usr/lib/python3.8/site-packages/plex_mpv_shim/mpv_shim.py”, line 39, in main
from .gui_mgr import userInterface
File “/usr/lib/python3.8/site-packages/plex_mpv_shim/gui_mgr.py”, line 4, in
import tkinter as tk
File “/usr/lib/python3.8/tkinter/init.py”, line 36, in
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
2020-08-28 17:37:08,885 [ INFO] player: Using libmpv1 playback backend.
2020-08-28 17:37:09,300 [ ERROR] menu: Could not load profile manager.
Traceback (most recent call last):
File “/usr/lib/python3.8/site-packages/plex_mpv_shim/menu.py”, line 63, in init
profile_manager = VideoProfileManager(self, playerManager)
File “/usr/lib/python3.8/site-packages/plex_mpv_shim/video_profile.py”, line 24, in init
self.load_shader_pack()
File “/usr/lib/python3.8/site-packages/plex_mpv_shim/video_profile.py”, line 36, in load_shader_pack
raise FileNotFoundError(“Could not find default shader pack.”)
FileNotFoundError: Could not find default shader pack.
2020-08-28 17:37:09,622 [ INFO] root: Started GDM service
2020-08-28 17:37:09,623 [ INFO] client: Started HTTP server

It does however now show up in my list of devices to cast to!

But I get an error when I try to cast to it.

None of those errors are fatal. The first one means the GUI can’t load, so it used the CLI mode as a fallback. The second one means the shader feature isn’t available, likely because the shader pack isn’t included by the AUR package.

Are you able to to select the player from you mobile device?