Log in

View Full Version : How to write a filter which creates a clip from nothing?


wonkey_monkey
18th September 2014, 17:42
Hi,

I'd like to write a plugin which doesn't take a video clip as input, but does create one and return it as output.

Is there a "right" way to do this? How should I declare the constructor, which normally looks something like this:

example::example(PClip _child, IScriptEnvironment* env) :
GenericVideoFilter(_child) {

, since there is no PClip _child?

Do I create my own VideoInfo structure to create the output clip?

Does anyone have an example of some code for a filter which does this?

Thanks,

David

videoh
18th September 2014, 17:50
Isn't that just what source filters do?

Have a look at the source code for mpeg2source() for example. Or the source code for BlankClip() within Avisynth.

wonkey_monkey
18th September 2014, 17:54
Oh yeah, I suppose they do! I never connected them with what I'm trying to do - thanks!

ETA: Having said that, I've tried to wade my through the mpeg2source source, but it seems I just don't understand enough to make any sense of it. And I can't find the blankclip code in the Avisynth source...

raffriff42
18th September 2014, 20:28
And I can't find the blankclip code in the Avisynth source...Here: src/sources/source.cpp (http://avisynth2.cvs.sourceforge.net/viewvc/avisynth2/avisynth/src/sources/source.cpp?view=markup#l124)
(I've been searching the codebase a lot lately)

TheFluff
18th September 2014, 20:46
https://github.com/FFMS/ffms2/blob/master/src/avisynth/avssources.cpp#L27

Basically, put a VideoInfo in your filter class and init it in your filter constructor (it's called VI in the FFMS2 code I linked), then in your GetFrame() just call env->NewVideoFrame(VideoInfo) and put your stuff in there.

StainlessS
18th September 2014, 22:45
RandomSource:- http://forum.doom9.org/showthread.php?t=166546&highlight=randomsource