mpv, Plex for Windows, and Vulkan
2022-11-07–2022-11-10Plex for Windows supports configuring its underlying mpv video player
via a separate mpv.conf
file located at %LOCALAPPDATA%\Plex\mpv.conf
(create
it if it does not exist). Something one might wanna do is configure it to use
Vulkan:
gpu-api=vulkan
However, this alone will actually crash the application once any media is
played. Instead, we need to revert gpu-context
to its mpv default as well:
gpu-api=vulkan
gpu-context=auto
That is the solution out of the way for those that came here for it; the rest of this page will go into how this was figured out.
Investigation
So let's go back to that first attempt at enabling Vulkan:We are cheating a little here by introducing vo=gpu-next
; it is not
necessary for Vulkan but it produces a much clearer error message later on
which helps to debug the application crash. Without it, the application crashes
with no obvious error message in the logs. I just so happened to have this
configuration set when I was originally debugging this.
gpu-api=vulkan
vo=gpu-next
Launch Plex for Windows and attempt to play any media. The application will
crash, but luckily there are logs, right? Let's check %LOCALAPPDATA%\Plex\Logs\
,
there are 1–5 log files here and the newest one is Plex.log
which should have
more information about the crash. Searching for something like "ERROR" might
yield multiple results, but we are interested in the last error which should be
the one that precedes the crash. That one looks like:
ERROR - [MPVEngine/mpv] vo/gpu-next: Failed initializing any suitable GPU context!
So now let's search the mpv manual; there are a few results for "GPU context",
but the most promising one is the gpu-context
setting. What is Plex for
Windows setting this value to? Is it different from mpv's default of auto? Well,
back to the logs:
DEBUG - [MPVEngine/mpv] cplayer: Set property: gpu-context="d3d11" -> 1
Ah, the application is trying to use gpu-context=d3d11
but that does not make
sense when we are trying to use Vulkan. So, we revert that to its mpv default
and that fixes everything:
gpu-api=vulkan
gpu-context=auto