View Full Version : How Do I Write a Filter with no clip argument
scmccarthy
7th December 2002, 17:55
I started writing a filter that creates color bars in YUY2 instead of RGB. But I stuck it in an old script I was using to test an RGB conversion filter.
After I got it working, I created an example script for it and discovered my problem. It won't work unless I open a clip even though it does nothing with the clip.
Once I remove the IClip* argument, GenericVideoFilter does not have a valid argument and can't be used.
So the real question becomes: How do you replace GenericVideoFilter or the argument it needs?
Stephen
dividee
7th December 2002, 18:40
When writing a source filter, it's better to inherit from IClip directly, not from GenericVideoFilter. Don't forget to initialize vi yourself then, and to implement each pure virtual function of IClip.
scmccarthy
7th December 2002, 21:07
@dividee
I was hoping I could side step implementing each pure virtual function. There are four of them now:
GetParity(int)
GetAudio(void *,__int64,__int64,IScriptEnvironment *)
SetCacheHints(int,int)
GetVideoInfo(void)
I tried this before after looking at source.cpp. Is this how I should start it then?
#include "avisynth.h"
class ColorBars_YV12 : public IClip {
VideoInfo vi;
public:
ColorBars_YV12(int _w, int _h) {
vi.width = _w;
vi.height = _h;
}
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};
Stephen
scmccarthy
7th December 2002, 22:00
Here's an update of my progress. This sort of works:
#include "avisynth.h"
class YUVColorBars : public IClip {
VideoInfo vi;
public:
YUVColorBars(int _h) {
vi.width = 720;
vi.height = _h;
vi.fps_numerator = 4;
vi.fps_denominator = 1;
vi.num_frames = 188;
vi.pixel_type = VideoInfo::CS_YUY2;
SetCacheHints(CACHE_NOTHING,0);
}
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
bool __stdcall GetParity(int n) { return false; }
void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env) { }
void __stdcall SetCacheHints(int cachehints,int frame_range) { };
const VideoInfo& __stdcall GetVideoInfo() { return vi; }
};
Media Player trys to download an activex component and then goes ahead and plays the clip.
Stephen
dividee
8th December 2002, 05:54
Media Player trys to download an activex component and then goes ahead and plays the clip.That's probably because you forgot to tell that the clip has no audio:
vi.audio_samples_per_second = 0;
scmccarthy
8th December 2002, 06:04
I am going to post before I try it. Certainly, that is right.
Thank you very much.
Trying to follow the internal ColorBars as an example didn't work, because it has audio.
Stephen
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.