In an effort to try to work around Plex’s behavior, I started to look into whether the mpv configuration could be overridden with a lua script. Here is what I’ve put together so far, but have never done this before and have only very minimally tested it. It is entirely possible it doesn’t do all of the setup needed to override whatever Plex tells mpv to use for the audio configuration (particularly if it has been fully reset), but it might be a helpful start for people to experiment with:
-- force Plex's mpv to use specific audio device settings
-- this is particularly useful if the WASAPI device endpoint name keeps
-- changing, which causes Plex to appear to reset all of the audio device
-- settings, since Plex does not provide a way to use the plain text
-- description to select the audio device
mp.observe_property("audio-device", "string", function(ad, plexaudiodev)
local myaudiodev = "wasapi/AUDIO-DEVICE-DESCRIPTION-HERE"
if plexaudiodev ~= myaudiodev then
mp.set_property("audio-device", myaudiodev)
mp.set_property("audio-channels", "2.0,2.1,3.1,5.1,7.1")
mp.set_property("audio-spdif", "ac3,eac3,truehd,dts,dts-hd")
mp.set_property("audio-exclusive", "yes")
end
end)
Just save this as force-audio-device.lua in the AppData\Local\Plex HTPC\scripts directory and replace AUDIO-DEVICE-DESCRIPTION-HERE with the description of the Audio Device you want to use (note that it still needs the wasapi/ prefix). If anyone has any input on other mpv options/settings that need to be configured for doing this, I’d be happy to add them!