Anime4K on Apple Silicon M1 Max and macOS

Wed Jan 05 2022

Failed to Load Shaders

I tried to setup Anime4K on my MacBook Pro with M1 Max according to the official guide, but it didn't work.

By checking the log, I found that the file path to shaders is not correct. mpv didn't parse the path string properly.

log
|
[file] Cannot open file '/Users/<USERNAME>/.config/mpv/shaders/Anime4K_Clamp_Highlights.glsl;~~/shaders/Anime4K_Restore_CNN_M.glsl;~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl;~~/shaders/Anime4K_AutoDownscalePre_x2.glsl;~~/shaders/Anime4K_AutoDownscalePre_x4.glsl;~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl': No such file or directory [stream] Failed to open /Users/<USERNAME>/.config/mpv/shaders/Anime4K_Clamp_Highlights.glsl;~~/shaders/Anime4K_Restore_CNN_M.glsl;~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl;~~/shaders/Anime4K_AutoDownscalePre_x2.glsl;~~/shaders/Anime4K_AutoDownscalePre_x4.glsl;~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl.

Solution

So I had to put the shader configurations inside profiles, and set shortcut to load the profile instead of to load shader via change-list as the official guide instructed.

  • mpv.conf
conf
|
# #Profile to load Anime4K shaders [Anime4K] glsl-shaders-append="~~/shaders/Anime4K_Clamp_Highlights.glsl" glsl-shaders-append="~~/shaders/Anime4K_Restore_CNN_M.glsl" glsl-shaders-append="~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl" glsl-shaders-append="~~/shaders/Anime4K_Restore_CNN_S.glsl" glsl-shaders-append="~~/shaders/Anime4K_AutoDownscalePre_x2.glsl" glsl-shaders-append="~~/shaders/Anime4K_AutoDownscalePre_x4.glsl" glsl-shaders-append="~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl"
  • input.conf
conf
|
# Clear loaded glsl-shaders; apply Anime4K shader profile CTRL+1 no-osd change-list glsl-shaders clr ""; apply-profile "Anime4K"; show-text "Profile: Anime4K" CTRL+` no-osd change-list glsl-shaders clr ""; show-text "GLSL shaders cleared"

HW+ and Performance

To turn on hardware acceleration, I had to add the following to mpv.conf:

conf
|
# #The default profile which sets some recommended settings profile=gpu-hq # #The called API # #Use "opengl" if you have compatibility issues.For displaying HDR content (not HDR -> SDR) "d3d11" is recommended (Windows only). gpu-api=vulkan # #Hardware decoding for whatever your CPU/GPU supports (e.g. 8bit h264 / 10bit h265) # #Only should be used when your CPU/GPU are very old, else avoid using it # #Use "auto-copy-safe" for the safest result in trade of better performance # #You can manually try "d3d11va" / "dxva2-copy" on Windows, "vaapi" / "vaapi-copy" on Linux or "nvdec" / "nvdec-copy" with an Nvidia GPUs hwdec=auto-safe

Anime4K: Mode A+A (Fast) is tested to be the best mode for my MacBook Pro with M1 Max.

Though it is working, I presume Anime4K is not optimized for Apple Silicon yet.