View Full Version : Visual Studio Community Edition 2022
Pier
21st January 2023, 20:33
Can I request a tutorial to setup an avisynth+ plugin project with Microsoft Visual Studio Community Edition 2022?
wonkey_monkey
21st January 2023, 22:54
This is just off the top of my head, but it might be enough to get you started before someone can give you better instructions. You'll need to have installed the SDK when you installed Avisynth+.
Start an empty project.
In Properties, General, change the configuration type to DLL.
In Include Directories, add the path to wherever avisynth.h is.
In Library Directories, add the path to wherever avisynth.lib is (selecting correct x86 or x64 directory for your build platform).
Under Linker->Input, add avisynth.lib as an Additional Dependency.
Then you can try compiling this: http://avisynth.nl/index.php/Filter_SDK/SimpleSample
I also add Post Build events to copy the compiled DLL straight to the AviSynth+ plugin folders:
copy $(TargetPath) "C:\Program Files (x86)\AviSynth+\plugins64\$(TargetFileName)"
Pier
22nd January 2023, 12:46
Thanks, I correctly compiled the plugin you linked. However, I made ChatGPT generate a greyscale plugin to test it:
#include <windows.h>
#include "avisynth.h"
class Greyscale : public GenericVideoFilter {
public:
Greyscale(PClip _child) : GenericVideoFilter(_child) {
vi.pixel_type = VideoInfo::CS_Y8;
}
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
PVideoFrame src = child->GetFrame(n, env);
PVideoFrame dst = env->NewVideoFrame(vi);
int src_pixel_size = src->GetPitch();
int dst_pixel_size = dst->GetPitch();
const BYTE* srcp = src->GetReadPtr();
BYTE* dstp = dst->GetWritePtr();
for (int i = 0; i < vi.height; i++) {
for (int j = 0; j < vi.width; j++) {
int r = srcp[i * src_pixel_size + j * vi.BytesFromPixels(1)];
int g = srcp[i * src_pixel_size + j * vi.BytesFromPixels(1) + 1];
int b = srcp[i * src_pixel_size + j * vi.BytesFromPixels(1) + 2];
int y = (r + g + b) / 3;
dstp[i * dst_pixel_size + j] = y;
}
}
return dst;
}
};
AVSValue __cdecl Create_Greyscale(AVSValue args, void* user_data, IScriptEnvironment* env) {
return new Greyscale(args[0].AsClip());
}
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment * env, const AVS_Linkage* const vectors) {
env->AddFunction("Greyscale", "c", Create_Greyscale, 0);
return "Greyscale Avisynth+ plugin";
}
And I get the following error:
https://ibb.co/bmJpH52
Can you help me figure out what's the problem?
wonkey_monkey
22nd January 2023, 13:11
Well, the main problem is trusting ChatGPT to give you a decent answer to anything. It's good at giving answers that look right, but aren't.
Have a look at SimpleSample and you'll see that it defines this globally:
const AVS_Linkage *AVS_linkage = 0;
and then sets its value in AvisynthPluginInit3:
AVS_linkage = vectors;
That may get you to compilation, but you'll find the ChatGPT code has bugs and omissions (and is not very efficient).
kedautinh12
22nd January 2023, 13:35
Yes, need train ChatGPT like Stainroid :D
Pier
22nd January 2023, 13:48
@ wonkey_monkey
Thanks, now it works. I learned my lesson :)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.