bloc97 / Anime4K

A High-Quality Real Time Upscaler for Anime Video
https://bloc97.github.io/Anime4K/
MIT License
18.21k stars 1.34k forks source link

Is it possible to have a reference mpv.conf in usage instructions? #84

Open Jules-A opened 4 years ago

Jules-A commented 4 years ago

Hi, this isn't really an issue so to speak but I've been following this project but haven't had too much success with it so far. Currently I'm using MPC-HC with MadVR (K-lite codec) with upscaling using NGU medium and downscaling using SSIM 2D (75%) with RBA, RCA and RRN activated and I'm pretty happy with the video quality but no matter what I try I can't seem to stop the audio popping (I managed to get it pretty rare using ffdshow to decode audio though). This obviously lead me to want to get Anime4k working well but so far my attempts haven't been very successful. While there is many guides to make video quality look better in mpv, I have no idea if I should activate them in conjunction with Anime4k shaders or what settings I should really use.

Currently I'm using these settings:

profile=gpu-hq scale=ewa_lanczossharp cscale=ewa_lanczossharp gpu-api=vulkan cursor-autohide=250 video-sync=display-resample interpolation tscale=oversample fs fs-screen=1

glsl-shaders="/shaders/Anime4K_3.0_Denoise_Bilateral_Mode.glsl;/shaders/Anime4K_3.0_Deblur_DoG.glsl;/shaders/Anime4K_3.0_DarkLines_HQ.glsl;/shaders/Anime4K_3.0_ThinLines_HQ.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl"

CTRL+1 change-list glsl-shaders set "/shaders/Anime4K_3.0_Upscale_CNN_L_x2_Denoise.glsl;/shaders/Anime4K_3.0_Auto_Downscale_Pre_x4.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl" CTRL+2 change-list glsl-shaders set "/shaders/Anime4K_3.0_Upscale_CNN_L_x2_Denoise.glsl;/shaders/Anime4K_3.0_Auto_Downscale_Pre_x4.glsl;/shaders/Anime4K_3.0_DarkLines_HQ.glsl;/shaders/Anime4K_3.0_ThinLines_HQ.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl" CTRL+3 change-list glsl-shaders set "/shaders/Anime4K_3.0_Upscale_CNN_L_x2_Denoise.glsl;/shaders/Anime4K_3.0_Auto_Downscale_Pre_x4.glsl;/shaders/Anime4K_3.0_Deblur_DoG.glsl;/shaders/Anime4K_3.0_DarkLines_HQ.glsl;/shaders/Anime4K_3.0_ThinLines_HQ.glsl;/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl" CTRL+4 change-list glsl-shaders set "/shaders/Anime4K_3.0_Denoise_Bilateral_Mode.glsl;/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl" CTRL+5 change-list glsl-shaders set "/shaders/Anime4K_3.0_Denoise_Bilateral_Mode.glsl;/shaders/Anime4K_3.0_DarkLines_HQ.glsl;/shaders/Anime4K_3.0_ThinLines_HQ.glsl;/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl" CTRL+6 change-list glsl-shaders set "/shaders/Anime4K_3.0_Denoise_Bilateral_Mode.glsl;/shaders/Anime4K_3.0_Deblur_DoG.glsl;/shaders/Anime4K_3.0_DarkLines_HQ.glsl;/shaders/Anime4K_3.0_ThinLines_HQ.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl" CTRL+0 change-list glsl-shaders clr ""

Unfortunately while lines appear to be handled better, MadVR does a far better job getting rid of noise or encoding artifacts. So I was wondering if there was something else I need to add to the conf or maybe even other shaders to remedy this issue? Btw I'm using Vulkan since default doesn't work on Windows and neither do the binds. Using an RX570.

bloc97 commented 4 years ago

Yes, MadVR has extensive de-noising processes. The goal of Anime4K was never really to denoise low quality encodes. High quality denoising/deblocking is inherently slow (there's no around it). You need an algorithm that has a very large receptive field. I would recommend denoising low quality encodes with something like waifu2x first. Strong real-time denoising softens the image too much.

Also, the CTRL+1, 2, 3... settings go into input.conf, and you don't need the glsl-shaders line if you use the keybindings.

Simply copy this into input.conf

CTRL+1 change-list glsl-shaders set "~~/shaders/Anime4K_3.0_Upscale_CNN_L_x2_Denoise.glsl;~~/shaders/Anime4K_3.0_Auto_Downscale_Pre_x4.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl"
CTRL+2 change-list glsl-shaders set "~~/shaders/Anime4K_3.0_Upscale_CNN_L_x2_Denoise.glsl;~~/shaders/Anime4K_3.0_Auto_Downscale_Pre_x4.glsl;~~/shaders/Anime4K_3.0_DarkLines_HQ.glsl;~~/shaders/Anime4K_3.0_ThinLines_HQ.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl"
CTRL+3 change-list glsl-shaders set "~~/shaders/Anime4K_3.0_Upscale_CNN_L_x2_Denoise.glsl;~~/shaders/Anime4K_3.0_Auto_Downscale_Pre_x4.glsl;~~/shaders/Anime4K_3.0_Deblur_DoG.glsl;~~/shaders/Anime4K_3.0_DarkLines_HQ.glsl;~~/shaders/Anime4K_3.0_ThinLines_HQ.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl"
CTRL+4 change-list glsl-shaders set "~~/shaders/Anime4K_3.0_Denoise_Bilateral_Mode.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl"
CTRL+5 change-list glsl-shaders set "~~/shaders/Anime4K_3.0_Denoise_Bilateral_Mode.glsl;~~/shaders/Anime4K_3.0_DarkLines_HQ.glsl;~~/shaders/Anime4K_3.0_ThinLines_HQ.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl"
CTRL+6 change-list glsl-shaders set "~~/shaders/Anime4K_3.0_Denoise_Bilateral_Mode.glsl;~~/shaders/Anime4K_3.0_Deblur_DoG.glsl;~~/shaders/Anime4K_3.0_DarkLines_HQ.glsl;~~/shaders/Anime4K_3.0_ThinLines_HQ.glsl;~~/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl"
CTRL+0 change-list glsl-shaders clr ""

and hold Ctrl and press 1, 2, 3, 4, etc... to activate one variant of the shader. Ctrl+0 turns off all shaders.

Edit: If you really want stronger denoising, you can edit the Anime4K_3.0_Denoise_Bilateral_Mode.glsl shader, and increase the STRENGTH parameter to something like 0.2 or 0.3 and the SPREAD_STRENGTH to 1.2 or 1.5. Append the filepath in front of the shader list if it is not already there, and use the appropriate keybind to enable it.

bloc97 commented 4 years ago

@Jules-A Here's a small comparison, let's say you have a very noisy image/video: image

Here's what it looks like after one pass of Denoise-Bilateral-Mode: image

And here's what it looks like with Denoise-Bilateral-Mode, but with STRENGTH 0.3 and SPREAD_STRENGTH 1.5 image

You can see the noise is almost completely gone, but some detail is gone aswell.

Jules-A commented 4 years ago

High quality denoising/deblocking is inherently slow (there's no around it). You need an algorithm that has a very large receptive field. I would recommend denoising low quality encodes with something like waifu2x first. Strong real-time denoising softens the image too much.

Hmm... it doesn't seem that slow in MadVR (I think I recall it being around a 30% overhead for all the options that could probably be classified as denoising. I didn't really notice it making things too soft either (I guess it gets fixed by sharpening?). waifu2x isn't really an option.

Simply copy this into input.conf

Oh wow I can't believe I made that mistake :/

If you really want stronger denoising, you can edit the Anime4K_3.0_Denoise_Bilateral_Mode.glsl shader, and increase the STRENGTH parameter to something like 0.2 or 0.3 and the SPREAD_STRENGTH to 1.5 or 2.0.

Yeah thanks, I might fiddle around with it.

Still though it didn't really solve my question about optimal mpv.conf file for use with Anime4k and if any options interfered with Anime4k or aren't generally recommended. I did however find this: https://github.com/Tsubajashi/mpv-settings which appears to be helpful but apparantly is using a modified Anime4k 3.0 shader but I haven't really looked into it yet.

Here's a small comparison

Yeah, that last image is definitely not good.

bloc97 commented 4 years ago

@Jules-A Just like in MadVR NGU denoising, the Anime4K_Upscale_x2_Denoise shaders have in-built denoising (for free, the neural network upscales and denoises at the same time). You can consider them to have the same effect as MadVR's denoising with a strength of 5 (which is not high at all). If you put the strength to 10 or 14 you can notice significant softening in parts of images where there are already softer textures. Maybe I will release stronger neural denoisers in the next release (v3.1), but for me, over-blurring an image looks worse than a small amount of noise (which gets smoothed out anyway since it is a video at 24-30fps and not a static image).

For the options, you don't need to worry too much about them, I personally don't find the effects of the in-built settings to be significant enough to matter. The perceptual quality of all traditional upscaling algorithms are pretty much the same: horrible. I personally use the default settings that come with mpv without any problems. I recommend tweaking the video-sync and temporal-scaling settings on an "as needed" basis, i.e. only if you notice some problems like stuttering when watching anime.

If you want a more technical answer, you can look at the mpv shader stage diagram, and know that Anime4K does all of its work on the NATIVE hook, just before the YCbCr to RGB conversion, so all the settings you tweak only affect the other parts of the shader stage. Most of them are applied after the Anime4K shaders. (With the exception of cscale, which affect the CHROMA plane, which come before Anime4K.)

Jules-A commented 4 years ago

Just like in MadVR NGU denoising, the Anime4K_Upscale_x2_Denoise shaders have in-built denoising

I tried that but it gets laggy using it on my system on 1080p content (I'm using a 1440p monitor if that matters). If you are wondering why I'm worried about noise on 1080p content it's because Crunchyroll encodes are disgusting (8Mb/s and it still looks like something from one of those illegal streaming sites...) . Here's it with mpv+Anime4k 1080p preset: https://i.imgur.com/P9YGrwj.png and here's it with mpc+MadVR: https://i.imgur.com/j3CekGJ.png (apologies for the lazy time difference)

Yes, it's MUCH softer but for some reason I didn't really notice it until I compared a show that's really blurry to begin with. That said, despite the softness, it clears up a tonne of the noise/artifacts which in my eyes is far greater quality.

bloc97 commented 4 years ago

@Jules-A Ah... I was unaware that Crunchyroll content was compressed to that point. Maybe a stronger denoiser would be warranted in the next version. But since you are watching 1080p content, feel free to crank up the Anime4K-Bilateral-Mode's STRENGTH settings as high as you want. (The comparison I made earlier was on 270p video, there's nowhere as much detail as that in a 1080p video.)

Oh if you could provide me with one or a few screenshots of what the compression on Crunchyroll looks like, I should be able to find an optimal setting for you and other Crunchyroll users.

I tried that but it gets laggy using it on my system on 1080p content

It shouldn't be, the denoise is free. Which shaders are you using in Anime4K? And what GPU do you have?

Jules-A commented 4 years ago

Ah... I was unaware that Crunchyroll content was compressed to that point.

Oh if you could provide me with one or a few screenshots of what the compression on Crunchyroll looks like, I should be able to find an optimal setting for you and other Crunchyroll users.

I'm not sure about Canada but Australia has quite a lot of free content you can watch even at 1080p (with ads obviously). It's probably not the best gauging by screenshots tbh. The newer content seems to be encoded a lot better but it seems all the old content is using old terrible encodes.

It shouldn't be, the denoise is free. Which shaders are you using in Anime4K? And what GPU do you have?

I was using the 1080p improve perceptual quality + deblur but I found that deblur was increasing the noise and so it looked worse on poorly encoded content. I tried glsl-shaders="shaders/Anime4K_3.0_Upscale_CNN_M_x2_Denoise.glsl;/shaders/Anime4K_3.0_DarkLines_HQ.glsl;/shaders/Anime4K_3.0_ThinLines_HQ.glsl;/shaders/Anime4K_3.0_Upscale_CNN_M_x2_Deblur.glsl"

But it's only just not able to keep up whereas L is much worse. GPU is an RX570.

Tsubajashi commented 4 years ago

I did however find this: https://github.com/Tsubajashi/mpv-settings which appears to be helpful but apparantly is using a modified Anime4k 3.0 shader but I haven't really looked into it yet.

Maker of the config here: its not really a modified anime4k shader, rather i did put the recommended shaders together. i'll clean that mess up later. I could possibly make a sample mpv config, which should work for everybody in my repo, if thats what you are after.

[Edited due to me being stupid when it comes to quoting things.]

Jules-A commented 4 years ago

Yeah, that would be good but I've tried some of your settings myself and I didn't quite agree with some but that may be due to personal preference, it seems all the tscale I've tried other than oversample produce too much blur/ghosting but I understand oversample is really heavy. Then there's other settings that are hard to test but I'm probably also looking for explanation on why that setting is chosen. I currently use dscale=ewa_robidoux but I've seen some shaders say they are optimized for mitchell. I guess what I'm looking for is official Anime4K compatible settings as maybe some settings may interfere with the Anime4K shaders.

Tsubajashi commented 4 years ago

Yeah, that would be good but I've tried some of your settings myself and I didn't quite agree with some but that may be due to personal preference, it seems all the tscale I've tried other than oversample produce too much blur/ghosting but I understand oversample is really heavy. Then there's other settings that are hard to test but I'm probably also looking for explanation on why that setting is chosen. I currently use dscale=ewa_robidoux but I've seen some shaders say they are optimized for mitchell. I guess what I'm looking for is official Anime4K compatible settings as maybe some settings may interfere with the Anime4K shaders.

tscale was chosen not because of oversample being heavy. im currently trying to find whats best. i "guess" profile=gpu-hq is the thing you want to have, and then the shaders. will make a reference mpv.conf, but i dont have the time right now sadly.