mpv for anime

Settings (and some scripts) I've found to be great for anime with mpv. I think I've managed to surpass the image quality of madvr (MPC-HC/NGU algorithm).

Stuff used in this article

Index

mpv.conf for image quality

profile=gpu-hq

###### DX on Windows (recommended)
gpu-api=d3d11
fbo-format=rgba16hf
###### OpenGL on Linux (recommended)
# gpu-api=opengl
# fbo-format=rgba16f
###### Vulkan on Linux/Windows (currently blurrier)
# gpu-api=vulkan
# fbo-format=rgba16hf

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

###### Luma up (choose FSRCNNX or SSimSuperRes)
glsl-shader="C:\path\to\mpv\shaders\FSRCNNX_x2_8-0-4-1_LineArt.glsl" # mathematically best, most expensive
# glsl-shader="C:\path\to\mpv\shaders\SSimSuperRes.glsl"             # really good, a little cheaper for the GPU
scale=ewa_lanczossharp

###### Luma down
glsl-shader="C:\path\to\mpv\shaders\SSimDownscaler.glsl"
dscale=mitchell
linear-downscaling=no
correct-downscaling=yes

###### Chroma up + down
glsl-shader="C:\path\to\mpv\shaders\KrigBilateral.glsl"
cscale=mitchell

###### Sharpen
# Didn't find this too useful with the SuperRes or FSRCNNX shader.
# glsl-shader="C:\path\to\mpv\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="C:\path\to\mpv\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
cursor-autohide=1000
save-position-on-quit
# No huge box on screen when turning the volume
osd-bar=no
osd-font-size=32
volume=100
volume-max=100
# A hotkey for this inside input.conf (k cycle audio-exclusive)
audio-exclusive=no

###### Lang & Sub (good for Japanese)
# Hide subtitles by default
sub-visibility=no
alang=jp,jpn,ja,en,eng
slang=jp,jpn,ja,en,eng
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

###### Screenshots
screenshot-format=webp
screenshot-webp-lossless=yes
screenshot-high-bit-depth=yes
screenshot-sw=no
screenshot-directory="C:\path\to\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

Custom shader settings

This shader is a bit subjective. It's similar to madVR's thin edges in "processing/image enhancements", but somewhat worse. A comparison here: slow.pics/c/gta4kYRE.

Decreased the strength of Anime4K_ThinLines_HQ.glsl 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
=================================
=== 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 FCRCNNX 
+ Added correct-downscaling=yes
- Disabled ThinLines
* Made the structure a bit clearer
* Moved the bit about refresh rates to its own section

=== Initial version ===

animated avatar

By Marko Leinikka