How to Use Custom GLSL Shaders in mpv?

Using custom GLSL shaders like Anime4K, Ravu, or FSRCNNX in the mpv media player is entirely possible and highly effective for upscaling and sharpening video content. This overview details how to install and configure these external shaders, enabling features like high-quality real-time anime upscaling or advanced neural network scaling. By modifying your configuration files, you can seamlessly activate, chain, or hotkey these custom shaders to maximize your display’s visual potential.

Prerequisites and Compatibility

To use external GLSL shaders, your version of mpv must be compiled with GPU video output support. You will need a compatible graphics processing unit (GPU) because advanced algorithms like Anime4K and Ravu rely heavily on real-time hardware rendering.

Before loading external shaders, ensure that your main configuration file utilizes high-quality processing defaults.

Step-by-Step Shader Installation

1. Locate or Create the Shaders Directory

You must place the downloaded .glsl shader files into a designated subfolder within your primary mpv configuration directory.

2. Download and Extract the Shaders

Download the desired shader files from their official repository releases (such as the GitHub pages for Anime4K or Ravu). Move the extracted .glsl files directly into the newly created shaders directory.

3. Edit the Configuration File (mpv.conf)

To make mpv load a shader automatically every time you open a video, add the glsl-shader or glsl-shaders property to your mpv.conf file located in the root of your mpv folder.

Use the ~~/ shortcut to tell mpv to look inside its own configuration directory.

# Enable high-quality rendering profile
profile=gpu-hq

# Load a single shader (e.g., Ravu)
glsl-shader="~~/shaders/ravu-lite-r4.glsl"

# Alternatively, load multiple shaders separated by colons (Linux/macOS) or semicolons (Windows)
# glsl-shaders="~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl"

Assigning Hotkeys for On-the-Fly Toggling

Instead of forcing a shader to run universally, you can create manual keyboard shortcuts to turn shaders on or off mid-playback. Create a text file named input.conf in your main mpv folder and use the change-list glsl-shaders command.

# Press CTRL+1 to enable an Anime4K upscaling chain
CTRL+1 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl"

# Press CTRL+2 to enable Ravu
CTRL+2 no-osd change-list glsl-shaders set "~~/shaders/ravu-lite-r4.glsl"

# Press CTRL+0 to clear all active GLSL shaders
CTRL+0 no-osd change-list glsl-shaders clr ""

Performance and Selection Tips

Different shaders place varying loads on your system architecture:

Shader Family Primary Target Performance Impact Best Used For
Anime4K Animation / Line Art Low to Moderate (Scale dependent) Enhancing edge crispness and removing compression artifacts in anime.
Ravu General Scaling Moderate High-quality, balanced neural network upscaling for mixed content.
FSRCNNX Fidelity / Realism High Purist upscale setups aiming for pixel-accurate reconstruction.

Keep an eye on system performance when experimenting with these tools. If you notice dropped frames during playback, hit the I key to bring up mpv’s internal statistics overlay and check if your GPU is struggling to keep up with the shader passes.