bloc97 / Anime4K

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

[Question] Anime4K auto change shader based on resolution #143

Closed Yuki-Soul closed 2 years ago

Yuki-Soul commented 2 years ago

Is there anyway to change shader based on screen resolution?

Y0ba commented 2 years ago

You can use auto-profiles script and conditionally apply settings in mpv.conf. Here is reduced profile that I use. It's even possible to apply different settings for files depending on their path. In my example all files with "Anime" in path got their own xxx-anime profiles:

[uhd]
profile-desc=cond:(get('video-params/w', 0)>=3840 or get('video-params/h', 0)>=2160)
glsl-shaders="..." #uhd shaders

[fhd]
profile-desc=cond:(((get('video-params/w', 0)>=1920 or get('video-params/h', 0)>=1080) and get('video-params/w', 0)<3840 and get('video-params/h', 0)<2160) and get('path', ''):find('Anime') == nil)
glsl-shaders="..." #non-anime fullhd shaders

[fhd-anime]
profile-desc=cond:(((get('video-params/w', 0)>=1920 or get('video-params/h', 0)>=1080) and get('video-params/w', 0)<3840 and get('video-params/h', 0)<2160) and get('path', ''):find('Anime') ~= nil)
glsl-shaders="..." #anime fullhd shaders

[hd]
profile-desc=cond:(((get('video-params/w', 0)>=1280 or get('video-params/h', 0)>=720) and get('video-params/w', 0)<1920 and get('video-params/h', 0)<1080) and get('path', ''):find('Anime') == nil)
glsl-shaders="..." #non-anime hd shaders

[hd-anime]
profile-desc=cond:(((get('video-params/w', 0)>=1280 or get('video-params/h', 0)>=720) and get('video-params/w', 0)<1920 and get('video-params/h', 0)<1080) and get('path', ''):find('Anime') ~= nil)
glsl-shaders="..." #anime hd shaders

[sd]
profile-desc=cond:((get('video-params/w', 0)~=0 and get('video-params/h', 0)~=0 and get('video-params/w', 0)<1280 and get('video-params/h', 0)<720) and get('path', ''):find('Anime') == nil)
glsl-shaders="..." #non-anime sd shaders

[sd-anime]
profile-desc=cond:((get('video-params/w', 0)~=0 and get('video-params/h', 0)~=0 and get('video-params/w', 0)<1280 and get('video-params/h', 0)<720) and get('path', ''):find('Anime') ~= nil)
glsl-shaders="..." #anime sd shaders
Y0ba commented 2 years ago

In my example I use original video width (video-params/w) and height (video-params/h). For display width/height you can use display-width and display-height properties. Full list of properties is here: https://mpv.io/manual/master/#property-list

hooke007 commented 2 years ago

You are using the deprecated (by upstream) script, mpv has its implement https://mpv.io/manual/master/#conditional-auto-profiles

mhtvsSFrpHdE commented 2 years ago

Hi, I made a mpv Lua script to enable Anime4K depending on video resolution, check it out!

https://github.com/mhtvsSFrpHdE/AnimeAnyK-mpv

Yuki-Soul commented 2 years ago

Hi, I made a mpv Lua script to enable Anime4K depending on video resolution, check it out!

https://github.com/mhtvsSFrpHdE/AnimeAnyK-mpv Looks Great, I will try it.