View Full Version : can a filter return a value to the script?
hanfrunz
22nd March 2004, 22:19
Hello,
is it possible, that a filter returns a value to a script?
I'd like to code a keyframe-filter (with GUI) so you can set marks in the video (keyframes=KF). For every KF you can choose a filtersetting (=the value will be returned)
example:
i set two KF at frame 200 and 500 (clip is 1000f long):
KF1: frame=200, filtersetting 1
KF2: frame=500, filtersetting 2
my script:
clip=AVISource("movie.avi")
setting=Keyframefilter(clip,"Keyframelist.txt",s0="do nothing",s1="blur",s2="sharpen")
if (setting=00) then v=clip
if (setting=01) then v=clip.blur(1.0)
if (setting=02) then v=clip.sharpen()
return v
So:
frame [000 - 199] stay untouched
frame [200 - 499] get blured
frame [500 - end] get sharper
hanfrunz
sh0dan
22nd March 2004, 22:21
ConditionalReader (http://www.avisynth.org/index.php?page=ConditionalReader) should do half of what you want.
ConditionalFilter (http://www.avisynth.org/index.php?page=ConditionalFilter) should do the other half.
v = Xsource()
blurred = blur(v,1.0)
sharpened = blur(v,-1.0)
conditionalfilter(v,blurred,v,"blurmode", "=", "1")
conditionalfilter(last,sharpened,last,"blurmode", "=", "2")
conditionalreader("blursettings.txt", "blurmode")
blursettings.txt:
type int
default 0
R 200 499 1
R 500 1499 2
hanfrunz
22nd March 2004, 22:33
okay i have to do the textfile thing... :(
mmh then my filter could generate a complete script.
maybe possible in a new version ? ;)
hanfrunz
sh0dan
22nd March 2004, 22:42
... but doesn't it do exactly what you describe? :confused:
hanfrunz
22nd March 2004, 22:49
yes of course it does, but will i see the changes immediately, when i shuttle through the video? Mmh is this done with my first idea? Or is it possible to put a avisynth-script in a filter (like in ffdshow)?
That would be interesting...
Fizick
5th April 2004, 05:51
I have similar question.
Can a one filter (my own source) get some info about every frame from other my filter (or other instance of first filter)?
Not through a file.
Bidoche
5th April 2004, 16:08
@Fizick
You can code filters so one will directly (ie without script knowledge) get info from another one you made.
Fizick
5th April 2004, 18:55
I can... Good.
But how? any example or MORE detailed info, please.
Have a look here (http://neuron2.net/ipw-web/bulletin/bb/viewtopic.php?t=37&highlight=hints)
neuron2 invented a system for his Decomb package and I've also copied it for PFR to pass info to KernelDeInt.
All code is available at our sites.
regards
Simon
Bidoche
6th April 2004, 14:16
@Fizick
Neuron2 uses extra space in frame buffer to hold his own data, ... as a workaround for the lack of frame properties.
It works fine as long as there is no filter between which may alter your metadata. (Filters are NOT required to leave the extra space alone, and in fact they often write on it)
If that restriction is unacceptable to you, you can do it like this : (STL code)
#include <map> //for map
#include <string> //for string
#include <utility> //for pair
class InterrogatedFilter
{
typedef std::map<pair<IScriptEnvironment *, std::string>, Clip *> InstanceMap;
static InstanceMap map_;
InterrogatedFilter(std::string const& identif, IScriptEnvironment *env)
{
map_[ std::make_pair(env, identif) ] = this; //reg self into map
}
~InterrogatedFilter()
{
for(InstanceMap::iterator it = map_.begin(); it != map_.end(); ++it )
if ( it->second == this )
{
map_.erase(it);
break;
}
//remove the entry corresponding to this from the instance map
}
static PClip FindInstance(std::string const& identif, IScriptEnvironment *env)
{
InstanceMap::iterator it = map_.find( std::make_pair(env, identif) );
return it != map.end() ? PClip(it->second) : PClip();
}
//Clip methods and interrogation methods ....
};//InterrogatedFilter
class InterrogatingFilter
{
//use InterrogatedFilter::FindInstance somewhere to fetch the (right) clip to interrogate...
//that means you must have the same identif value here to use
};
NB: this is not perfect (not thread safe for example)
Fizick
6th April 2004, 18:56
Thanks!
I shall try that strange method.
Corrected: methodS.
Bidoche
7th April 2004, 15:19
Well, I would have called using an instance map a classic solution. :p
Anyway, if you have trouble doing that, feel free to ask.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.