View Full Version : Unable to use Anime4KCPP AviSynth plugin
stax76
18th December 2020, 12:41
I'm not able to use the Anime4KCPP avisynth plugin, is this maybe a problem with my PC or does it generally not work? It gives an access violation here. Maybe somebody can confirm that it's generally not working, so I can make a proper bug report. Under vapoursynth it works.
https://github.com/TianZerL/Anime4KCPP
ChaosKing
18th December 2020, 12:55
Works fine here. x64 avs+ 3.6.2 (3328)
Post your paramaters + source resolution.
stax76
18th December 2020, 14:38
script properties:
Width : 1920
Height : 1080
Frames : 7415
Time : 04:07.414
Framerate : 29.970029 (30000/1001)
Format : YUV420P8
avs code:
LoadPlugin("C:\Anime4KCPP AviSynth\Anime4KCPP_AviSynthPlus.dll")
Anime4KCPP(GPUMode = true, zoomFactor = 2, ACNet = true, HDN = true, HDNLevel = 1)
Win10 20H2
avs+ 3.6.2 test6 x64
Could it be my GT 1030 card?
Or maybe VC++ runtime? Using 2020-11-11.
ChaosKing
18th December 2020, 14:52
I used the same setting in my test.
I would check if opencl is checked in gpu-z. If not reinstall driver.
Have you also copied the opencv_world440.dll?
stax76
18th December 2020, 15:06
OpenCL is checked in GPU-Z
opencv_world440.dll is in the same folder as the plugin.
The included VC++ files were deleted because they are already installed and staxrip has an all-in-one package included and added to PATH, it works using vapoursynth.
Exception thrown at 0x00007FFBCB0B19FE (Anime4KCPP_AviSynthPlus.dll) in StaxRip.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
ChaosKing
18th December 2020, 15:07
hmm then idk.
stax76
18th December 2020, 15:30
Ok thanks anyway.
Reel.Deel
18th December 2020, 20:49
I too had problems with Anime4KCPP with AviSynth+, and never did get it to work: https://forum.doom9.org/showthread.php?p=1914801#post1914801
StainlessS
18th December 2020, 21:57
StaxRip.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
Is likely bug in Anime4KCPP, could happen when eg some chunk of mem alloc request was of Out-Of-Mem situation,
returned a null (zero) pointer, and the the filter tried to access the mem pointed to by the null pointer, it is illegal
in any software on any machine [that I'm aware of] to try read mem location 0, except in supervisory OS mode, where location 0 may
often store address of BIOS/Firmware startup rountine [@ machine switch on, CPU jumps to location stored @ mem 0].
TianZerL
19th December 2020, 09:16
Hi, I am the developer of Anime4KCPP.
If you don't specify the input clip for Anime4KCPP, there will be a "System exception - Access Violation".
So your code:
LoadPlugin("C:\Anime4KCPP AviSynth\Anime4KCPP_AviSynthPlus.dll")
Anime4KCPP(GPUMode = true, zoomFactor = 2, ACNet = true, HDN = true, HDNLevel = 1)
should be:
LoadPlugin("C:\Anime4KCPP AviSynth\Anime4KCPP_AviSynthPlus.dll")
Anime4KCPP(src = clip, GPUMode = true, zoomFactor = 2, ACNet = true, HDN = true, HDNLevel = 1)
or:
LoadPlugin("C:\Anime4KCPP AviSynth\Anime4KCPP_AviSynthPlus.dll")
FFVideoSource("Test .mp4").Anime4KCPP(GPUMode = true, zoomFactor = 2, ACNet = true, HDN = true, HDNLevel = 1)
ChaosKing
19th December 2020, 10:12
Haha yes that sould be problem.
I tried
ffms()
Anime4KCPP()
and got an Access Violation. In my previous test I tested with
ffms().Anime4KCPP()
which works fine.
Is this a bug or a feature? :D
TianZerL
19th December 2020, 11:04
It seems that if there is no clip input parameter in the parameter list of the filter, AviSynth will automatically select one.
Anime4KCPP got one, so clip input must be manually determined.
I don't think this is a bug. It is sometimes necessary to clearly indicate the clip to be processed.
Now Anime4KCPP supports only processing grayscale channels. We may split a video, and multiple clips will appear.
ChaosKing
19th December 2020, 11:07
Is it possible to detect this and then just throw an error message with some usefull text?
Btw. I think in the Vapoursynth version, Anime4KCPP should automatically call std.crop() if the resolution is not a multiple of 32 and crop the "garbage" away. https://github.com/TianZerL/Anime4KCPP/issues/11
TianZerL
19th December 2020, 11:10
Good idea, i will try it.:D
TianZerL
19th December 2020, 11:15
Is it possible to detect this and then just throw an error message with some usefull text?
Btw. I think in the Vapoursynth version, Anime4KCPP should automatically call std.crop() if the resolution is not a multiple of 32 and crop the "garbage" away. https://github.com/TianZerL/Anime4KCPP/issues/11
In the new VapourSynth version, it will automatically use the safe mode, which has no extra pixels, and the performance may be better. see wiki https://github.com/TianZerL/Anime4KCPP/wiki/VapourSynth-plugin#weird-border
ChaosKing
19th December 2020, 11:53
:thanks:
stax76
19th December 2020, 12:19
Haha yes that sould be problem.
I tried
ffms()
Anime4KCPP()
and got an Access Violation. In my previous test I tested with
ffms().Anime4KCPP()
which works fine.
Is this a bug or a feature? :D
I thought this code is equal. :confused:
TianZerL
19th December 2020, 12:39
No, it is not equal.
ffms().Anime4KCPP()
mean's make ffms()'s output clip as input of Anime4KCPP()
ffms()
Anime4KCPP()
is just two unrelated function calls. You need to pass the parameters manually:
clip = ffms()
Anime4KCPP(src = clip)
ffms().Anime4KCPP() is actually equal to Anime4KCPP(src = ffms())
stax76
19th December 2020, 12:45
I'm not really an avisynth expert, following are just speculations... I think there is a magic variable called Last, so if your input is empty maybe just query this variable, that's maybe how all filters do it.
http://avisynth.nl/index.php/Grammar
ChaosKing
19th December 2020, 12:59
I found this "avs magic" always a bit weird. It works good for simple scripts, but in more complex scripts it can have unexpected behaviour. That's why I try to use variables most of the time, like in vapoursynth.
TianZerL
19th December 2020, 13:10
This "magic variable" only works if a filter has an anonymous clip input parameter in it's parameters list.
In this case, you need to specify the clip input (c mean this is a clip parameters)
env->AddFunction("Anime4KCPP",
"[src]c",
createAnime4KCPP, 0);"
And in this case, magic happens
env->AddFunction("Anime4KCPP",
"c,"
createAnime4KCPP, 0);"
Relying on this syntactic sugar may cause some problems. So I decided to keep the name "src".
stax76
19th December 2020, 13:33
Looks like a pitfall for noobs like me, but also pro users like Reel.Deel stumbled into it.
Selur
19th December 2020, 19:36
Good that this got cleared up. :)
StainlessS
19th December 2020, 19:53
If you specify a name for clip c, ie src, then is optional and need to supply default value [here NULL] so that can detect
caller error. It should not have had an optional name specified, too late to change now really, so must detect error rather than
throw unhandled exeption.
Without an optional name, Avisynth does check on supplied clip arg, and throws error for you, if missing.
Something like [untested]
env->AddFunction("Anime4KCPP",
"[src]c",
createAnime4KCPP, 0);"
...
//
AVSValue __cdecl createAnime4KCPP(AVSValue args, void* user_data, IScriptEnvironment* env) {
PClip child;
if((child = args[0].AsClip(NULL)) == NULL) // default value
env->ThrowError("We Done Bad");
return new SomeFunc(child);
}
EDIT: Also applies to Script functions, in script func prototype, if arg wrapped in quotes, "src", then src is optional
and have to supply default arg and trap if Src.IsClip via some Assert.
If arg is compulsory, never specifiy as optional without good cause.
feisty2
19th December 2020, 20:34
I found this "avs magic" always a bit weird. It works good for simple scripts, but in more complex scripts it can have unexpected behaviour. That's why I try to use variables most of the time, like in vapoursynth.
py is extremely dynamic, this implicit "last" thing could be emulated by dynamically overriding __call__() for vaporsynth extensions using ctypes. :devil:
ChaosKing
19th December 2020, 21:28
py is extremely dynamic, this implicit "last" thing could be emulated by dynamically overriding __call__() for vaporsynth extensions using ctypes. :devil:
Is this the missing piece of puzzle for switching from avs to vs? :D
feisty2
19th December 2020, 21:52
Is this the missing piece of puzzle for switching from avs to vs? :D
I wrote some python hacks a while ago to make vaporsynth scripting even easier than avisynth (https://github.com/IFeelBloated/VaporMagik/blob/master/Test.vpy), but never thought to implement this implicit "last" thing. it's just, I don't know, weird? unsafe? confusing? poor taste in general? to pass an argument via side effect for a function call
real.finder
19th December 2020, 22:06
easier than avs? unless you can use ffmpeg.exe with just VapourSynth.dll without external python :D , And guess what? it can by only ffmpeg.exe https://github.com/AviSynth/AviSynthPlus/pull/192
real.finder
19th December 2020, 22:12
Relying on this syntactic sugar may cause some problems. So I decided to keep the name "src".
what problem?! all filters do it that way
feisty2
19th December 2020, 22:19
by easier, I mean easier to write a script, and there're ffmpeg builds with direct vaporsynth support. this is getting off topic so I won't further respond to such trolling comment.
ChaosKing
19th December 2020, 22:32
@feisty2 Thx, I will try it in my next project. This was the most annoying thing in the beginning after switching from avs to vs, not beeing able to use clip.MyPyFunc() like the plugin syntax,
TianZerL
20th December 2020, 07:49
what problem?! all filters do it that way
Personally, I don't use AviSynth very often, but I occasionally work with multiple video streams in one script in VapourSynth, so I think it's necessary to provide clip input that can be specified explicitly. In view of AviSynth's actual situation, I think it would be a good idea to provide both anonymous clip and manually specified clip interfaces.
TianZerL
20th December 2020, 08:01
If you specify a name for clip c, ie src, then is optional and need to supply default value [here NULL] so that can detect
caller error. It should not have had an optional name specified, too late to change now really, so must detect error rather than
throw unhandled exeption.
Without an optional name, Avisynth does check on supplied clip arg, and throws error for you, if missing.
Something like [untested]
env->AddFunction("Anime4KCPP",
"[src]c",
createAnime4KCPP, 0);"
...
//
AVSValue __cdecl createAnime4KCPP(AVSValue args, void* user_data, IScriptEnvironment* env) {
PClip child;
if((child = args[0].AsClip(NULL)) == NULL) // default value
env->ThrowError("We Done Bad");
return new SomeFunc(child);
}
EDIT: Also applies to Script functions, in script func prototype, if arg wrapped in quotes, "src", then src is optional
and have to supply default arg and trap if Src.IsClip via some Assert.
If arg is compulsory, never specifiy as optional without good cause.
This is what I decided to do to provide more friendly error messages about "access violation" in the new version
real.finder
20th December 2020, 17:28
Personally, I don't use AviSynth very often, but I occasionally work with multiple video streams in one script in VapourSynth, so I think it's necessary to provide clip input that can be specified explicitly. In view of AviSynth's actual situation, I think it would be a good idea to provide both anonymous clip and manually specified clip interfaces.
vs is not like avs, I think you should make it c not [src]c, all avs filters do it that way
Is there a little more verbose documentation with practical suggestions?
E.g. in which cases may more passes than just the default of 2 make sense, etc.?
I may be wrong, but it seems to me that the number of passes does not change one bit on the output in OpenCL mode.
tormento
13th June 2025, 10:13
Is there a little more verbose documentation with practical suggestions?
Why don't you use mlrt?
LigH
13th June 2025, 10:29
Because I never heard of it yet?
_
Also, seems to be quite demanding. What will work with just some compromise hardware?
LigH
14th June 2025, 11:52
Alright, I am able to use mlrt_RealESRGAN with ncnn backend on my GeForce 1660 Super with 6 GB. Trying to use CUGAN mostly failed (with exception of single frames before crashing).
RealESRGAN with ort backend is extremely slow and very CPU intense; seems that it doesn't use CUDA?
Ah, the syntax is a little complex:
mlrt_RealESRGAN(model=2, backend=["ort", """provider="CUDA" """])
LigH
15th June 2025, 15:34
It works better on my GeForce 1660 Super with:
mlrt_CUGAN(backend=["ncnn", "fp16=true"])
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.