mpv for anime


Opinionated settings (and some scripts) I've found to be great for anime with mpv, matching and even surpassing the image quality of madvr (MPC-HC/NGU algorithm).

# TL;DR / Quick Guide

  1. Install mpv
  2. Download shaders and place them to mpv/shaders/:
    1. Luma Upscaler:
      • FSRCNNX (FSRCNNX_x2_8-0-4-1_LineArt.glsl inside the checkpoints_params.7z)
      • or
      • SSimSuperRes (lighter on the GPU, but almost as good as FSRCNNX)
    2. Luma Downscaler: SSimDownscaler
    3. Chroma Up/Downscaler: KrigBilateral
  3. Copy & paste the image quality config below to mpv/mpv.conf
  4. Uncomment either FSRCNNX or SSimSuperRes (not both) at the Luma up section in the config
  5. (Optional, Windows) Comment the two Vulkan lines and uncomment DirectX lines at the start of the config for better performance in some cases
  6. (Optional) Download scripts to mpv/scripts/

Links

Index

# mpv.conf for image quality

profile=gpu-hq

# Not too important on modern hardware. 'auto-copy-safe' is a safe option to use if one wants to enable it. Defaults to 'no'.
#hwdec=no

# Video driver to use. I recommend using the stable older 'gpu' (default) or the new experimental 'gpu-next'. Latter might still have various issues.
#vo=gpu

###### Vulkan on Linux, Windows or macOS (recommended)
gpu-api=vulkan
fbo-format=rgba16hf

###### DirectX on Windows (recommended)
#gpu-api=d3d11
#fbo-format=rgba16hf

###### OpenGL on Linux or macOS or Windows
#gpu-api=opengl
#fbo-format=rgba16f

###### Color gamut
# https://github.com/mpv-player/mpv/issues/9071
# Noticed that for example in the Evangelion 3.333 4K version reds look wrong when gamut-clipping is enabled. Uncomment at your discretion.
#gamut-clipping=no       # only mpv v0.34.1 https://mpv.io/manual/stable/#options-gamut-clipping
#gamut-mapping-mode=clip # only mpv git or newer https://mpv.io/manual/master/#options-gamut-mapping-mode
#hdr-compute-peak=no

###### Shaders ######

###### Luma up (uncomment FSRCNNX or SSimSuperRes, not both)
#glsl-shader="~~/shaders/FSRCNNX_x2_8-0-4-1_LineArt.glsl" # mathematically best, most expensive
#glsl-shader="~~/shaders/SSimSuperRes.glsl"               # really good, a little cheaper for the GPU
scale=ewa_lanczossharp

###### Luma down
glsl-shader="~~/shaders/SSimDownscaler.glsl"
dscale=mitchell
linear-downscaling=no
correct-downscaling=yes

###### Chroma up + down
glsl-shader="~~/shaders/KrigBilateral.glsl"
cscale=mitchell

###### Sharpen
# Didn't find this too useful with the SuperRes or FSRCNNX shader.
#glsl-shader="~~/shaders/adaptive-sharpen.glsl"
#sigmoid-upscaling=no
#linear-upscaling=no

###### Thinlines
# Very subjective. Currently not using. Refer to the bottom of this post for configuring this.
#glsl-shader="~~/shaders/Anime4K_ThinLines_HQ.glsl"

###### Antiring
scale-antiring=0.7
dscale-antiring=0.7
cscale-antiring=0.7

###### Debanding
deband=yes
deband-iterations=4
deband-threshold=35
deband-range=16
deband-grain=4

# Other settings in my mpv.conf

###### General
keep-open=yes
snap-window=yes       # Snap to corners on Windows
cursor-autohide=1000
save-position-on-quit # Remember position when closing the player
osd-bar=no            # No huge box on screen when turning the volume
osd-font-size=32
volume=100
volume-max=100
audio-exclusive=no    # A hotkey for this inside input.conf (k cycle audio-exclusive)

###### Language & subtitles
sub-visibility=no      # Hide subtitles by default
alang=jp,jpn,ja,en,eng # Language priority for audio
slang=jp,jpn,ja,en,eng # Language priority for subtitles
sub-auto=fuzzy
sub-font='Arial'
sub-font-size=40
sub-border-size=1
sub-shadow-color=0.0/0.0/0.0/0.50
sub-shadow-offset=2

###### High-quality screenshots
screenshot-format=webp
screenshot-webp-lossless=yes
screenshot-high-bit-depth=yes
screenshot-sw=no
screenshot-directory="~~/screenshots"
screenshot-template="%f-%wH.%wM.%wS.%wT-#%#00n"

# input.conf

##### General
z          ignore
w          no-osd cycle sub-visibility
s          cycle sub
S          cycle sub down
F1         add sub-delay -0.1   
F2         add sub-delay +0.1
F5         no-osd screenshot
k          cycle audio-exclusive
p          add panscan -0.1
P          add panscan +0.1

WHEEL_UP   add volume   2
WHEEL_DOWN add volume  -2
RIGHT      seek   2 exact
LEFT       seek  -2 exact
UP         seek   5 exact
DOWN       seek  -5 exact
Ctrl+RIGHT seek  20 exact
Ctrl+LEFT  seek -20 exact

##### mpvacious
q          script-binding mpvacious-sub-seek-back
e          script-binding mpvacious-sub-seek-forward
x          script-binding mpvacious-sub-rewind

##### Better Chapters
MOUSE_BTN7 script_binding chapter_prev
MOUSE_BTN8 script_binding chapter_next

##### Bookmarker Menu
B          script_message bookmarker-menu
b          script_message bookmarker-quick-save
ctrl+b     script_message bookmarker-quick-load

# Refresh rate in mpv.conf

If for some reason (e.g. to have an exact match) you want to have the refresh rate to be specified, comment out these two lines. Can cause problems especially if the fps doesn't match with the display. mpv is usually pretty good at estimating the fps anyway so no real need to use these.

Refresh rate reported by the OS can be verified with testufo.

# Refresh rate of the monitor (143.856 = 6* 23.976, which is the standard video framerate)
override-display-fps=143.856

# 'display-vdrop' is basically the same as 'audio', but with better debugging in Shift+i menu
# Read more about this here: https://mpv.io/manual/master/#options-video-sync
video-sync=display-vdrop

# Anime4K

Anime4K has the wow factor but is still unreliable and doesn't succeed in preserving the original image. Personally, I don't use it, but some might find it good for their purposes. Comparison here (version 4.0RC): slow.pics/c/TZFEW7mT

Anime4K's Anime4K_Thin_*.glsl can be adjusted manually as well. It's similar to madVR's thin edges in "processing/image enhancements", but somewhat worse. A comparison here: slow.pics/c/gta4kYRE. I decreased the strength from 0.6 to 0.01 and increased iterations from 1 to 20:

#define STRENGTH 0.01 // Strength of warping for each iteration
#define ITERATIONS 20 // Number of iterations for the forwards solver, decreasing strength and increasing iterations improves quality at the cost of speed.

# CHANGELOG

=================================
+ Added
- Removed or disabled
* Change/information
=================================
=== 2022-07-11
+ Added a bit about hwdec and vo to the config
+ Added a step to the tl;dr guide to uncomment the Luma up shader in the config
=== 2022-04-03
+ Added more comments to explain some of the config options
* Make Vulkan default option with an optional step for Windows to switch to DirectX
* Changed how paths are defined to make them work out of the box
=== 2022-03-14
+ Added a bit about the mpv version this guide is based on
+ Added gamut-mapping-mode in mpv git to the config
* Commented out gamut clipping settings by default
=== 2022-02-22
* Fixed section title links
* Modified some phrasings
- Removed API (DirectX, OpenGL, Vulkan) partiality
=== 2021-12-18
+ Added a quick guide
* Modified comments and structure of the config
=== 2021-10-24
+ Added gamut-clipping and hdr-compute-peak to the config
=== 2021-09-26
* Fixed a typo
=== 2021-08-31
* More about anime4K
* Fixed anchor links
=== 2021-08-01 ===
+ Added a bit about Adaptive Sharpening
=== 2021-07-10 ===
+ Added autosubsync script
+ Added a new source: https://artoriuz.github.io/blog/mpv_upscaling.html
+ Added a comparison: https://slow.pics/c/NTryj7wb
+ Added index
+ Added changelog
+ Added FSRCNNX
+ Added correct-downscaling=yes
- Disabled ThinLines
* Made the structure a bit clearer
* Moved the bit about refresh rates to its own section

=== Initial version ===

By Marko Leinikka

(updated )