HTPC Tips and Tricks

Plex HTPC as well as Plex for Windows/Mac/Linux uses mpv as a playback engine which allows for a high degree of customization. Some of this thread’s intent is to outline some of the more advance customization. Note that some links here will go to other threads with info provided by users:

  1. Substituting your own MPV library
  2. Tuning for low power GPUs
  3. Higher Quality video
  4. Static HDR Metadata Passthrough
  5. Input Mapping for Scripts
  6. Modifying Windows’ Refresh Rates to Match Media

Most of this revolves around adding options to the mpv.conf file with MPV options. This file is located at these locations (it doesn’t exist by default so create it if you don’t have one):

  • Windows: %LocalAppData%\PlexHTPC\
  • MacOS: ~/Library/Application Support/Plex HTPC/
  • Linux: ~/snap/plex-htpc/common

Note: Sometimes when creating this file, you can accidentally create it as mpv.conf.txt and the .txt will be hidden from you. Be sure you create it with the correct name or it will be ignored.

3 Likes

Some users may want to replace the MPV library used with one of their own. One reason could be to experiment with new features available in MPV itself. Doing this is as simple as replacing the library in the install with desired version. On each platform, it appears that MPV builds ship without the shared library but Windows has a separate archive containing the library. So on other platforms you will need to build the library yourself and then follow instructions similar to these for Windows.

Windows:

  1. Quit the app
  2. In C:\Program Files\Plex\Plex HTPC rename mpv-2.dll to another file
  3. Download from mpv player (Windows) - Browse /libmpv at SourceForge.net (be sure to grab a version that contains x86_64)
  4. Copy the mpv-2.dll from the download to C:\Program Files\Plex\Plex HTPC

This build of the MPV library appears to be missing some of the certificate authorities necessary to connect to Plex Media Servers. Fortunately it can be told to use the one that ships with HTPC. You can do this by inserting this in your mpv.conf file (adjusting paths if you installed elsewhere):

tls-ca-file=C:\Program Files\Plex\Plex HTPC\resources\cacert.pem This is no longer necessary.

1 Like

Some hardware is barely able to do 4K HDR playback but the defaults in MPV are higher in quality (and thus requiring more GPU) than other players. If you are finding your hardware is dropping frames, you should first decrease the video quality settings in the applications settings.

If you are having difficulty playing HDR content, you should try adding this to your mpv.conf file:

hdr-compute-peak=no

Another possible option that may help is:

tone-mapping=reinhard

There are other options in the MPV manual to consider

There are many options which can be enabled in MPV to improve the video quality but will increase the GPU power necessary. All the options described here are available in the highest video quality options available on Windows with some available in lower quality settings as well. Those wondering what these entail (or want to attempt to use them on other platforms) are provided a description here. Many of these are taken from GitHub - classicjazz/mpv-config: MPV configuration files for high quality rendering of traditional live TV and video disc formats and can be added to your mpv.conf file. See first post for the location of this file

Debanding

MPV can detect and reduce color banding present in video. This is more often prevalent in low-light scenes. Debanding is turned on when you use the High and higher quality settings. However the strength and processing of the debanding can be increases with the following:

deband-iterations=4 # deband steps (https://mpv.io/manual/master/#options-deband-iterations: defaults to 1)
deband-threshold=48 # deband strength (https://mpv.io/manual/master/#options-deband-threshold: defaults to 32)

Anti-ringing

Sometimes when video is scaled up or down some artifacts may be introduced. The anti-ringing directives try to reduce these artifacts but could potentially introduce artifacts of their own.

scale-antiring=0.7 # luma upscale deringing (https://mpv.io/manual/master/#options-scale-antiring: defaults to 0)
dscale-antiring=0.7 # luma downscale deringing (https://mpv.io/manual/master/#options-dscale-antiring: defaults to 0)
cscale-antiring=0.7 # chroma upscale deringing (https://mpv.io/manual/master/#options-cscale-antiring: defaults to 0)

External Shaders

There are multiple external shaders available. Do not combine multiple shaders of the same type. Two possible configurations of the external scalers are listed below: See mpv Configuration Guide for Watching Videos – Kokomins for more information. A large list of available scalers can be found at User Scripts · mpv-player/mpv Wiki · GitHub.

SSimSuperRes

This scaler is used in the Ultra quality setting. It uses the SSimSuperRes external scaler to perform the scale operation. This will require a higher end GPU such as a GTX 1060 or higher to perform fast enough for video playback.

On Windows, the scaler is automatically copied into the shaders directory for you. On other OSs, you must first download the SSimSuperRes from https://gist.githubusercontent.com/igv/2364ffa6e81540f29cb7ab4c9bc05b6b/raw/SSimSuperRes.glsl and save it in the shaders directory (create if it doesn’t exist) next to your mpv.conf file.

Then add the following to your mpv.conf:

glsl-shaders="~~/shaders/SSimSuperRes.glsl" # Set B C parameter to Mitchell.
scale=haasnsoft
dscale=mitchell
cscale=ewa_lanczossoft

If you want a sharper image instead, you can use:

glsl-shaders="~~/shaders/SSimSuperRes.glsl" # Set B C parameter to Robidoux.
scale=ewa_lanczossharp
dscale=mitchell
cscale=spline64

The above mentions Set B C parameter to which is asking you to edit the shaders/SSimSuperRes.glsl file and change the 2 instances of #define Kernel(x) MN(0.334, 0.333, abs(x)). You change the two numbers to:

  • Catrom: 0, 0.5
  • Mitchell: 0.334, 0.333
  • Robidoux: 0.3782,0.3109

FSRCNN, SSimDownscale, and KrigBilateral

These scalers are used in the Make My GPU Hurt quality setting. This combination of shaders requires a really high end GPU to perform fast enough for video playback. This set of scalers uses a Fast Super Resolution Convolutional Neural Network (FSRCNN) as a 2x pre-scaler, SSimDownscale as a downscaler, and KrigBilateral as the scaler for the chroma channel. With this combination, when you play 720p content on a 1080p display, it is first doubled to 1440p using FSRCNN, then downscaled to 1080p using SSimDownscale, and the KrigBilateral scales the 360p chroma channel → 1080p (assuming 4:2:0 chroma subsampling is being used).

On Windows, the scalers are automatically copied into the shaders directory for you. On other OSs, you must first download the FSRCNNX scalers from: Releases · igv/FSRCNN-TensorFlow · GitHub, SSimDownscale from https://gist.githubusercontent.com/igv/36508af3ffc84410fe39761d6969be10/raw/SSimDownscaler.glsl, and KrigBilateral from https://gist.githubusercontent.com/igv/a015fc885d5c22e6891820ad89555637/raw/KrigBilateral.glsl. Place these in the shaders directory.

Then add the following to your mpv.conf file:

# luma upscaling
glsl-shaders="~~/shaders/FSRCNNX_x2_8-0-4-1.glsl"
scale=ewa_lanczos
# luma downscaling
# note: ssimdownscaler is tuned for mitchell and downscaling=no
glsl-shaders-append="~~/shaders/SSimDownscaler.glsl"
dscale=mitchell
linear-downscaling=no
# chroma upscaling and downscaling
glsl-shaders-append="~~/shaders/KrigBilateral.glsl"
cscale=mitchell
sigmoid-upscaling=yes

Audio Drops

When I had done the above on an RTX 2060, I started getting audio drops in certain content. The solution was to go into the NVIDIA Control Panel -> Manage 3D Settings -> Power Management Mode and change it to Prefer Maximum Performance.