View Full Version : Quick question: can I use a string to designate which clip I want to use?
I wonder..
Can i set a string for a mode, then piece together another string by mode + "string", and then use that string as a clip title to be used?
My poor little mind can't think of a way. Thanks in advance :).
Edit: since nobody replied, I'll be less cryptic (although I thought I was clear enough). I wanna do this:
function blah(clip c, string mode) {
shibbyblah = c.Some().Filters().Here()
shaggyblah = c.Some().More().Filters().Here()
shabbyblah = c.Some().More().Filters(with="arguments").Here()
modeclip = mode + "blah"
modeclip.I().Love().AVISynth()
}
blah(mode=shaggy)
Maybe that's a bit more clear ;).
Guest
31st May 2003, 19:03
Use this:
a=AVISource("youravi.avi")
function DoIt(clip c, string mode)
{
vid = (mode == "raw" ? c : (mode == "gray" ? c.Tweak(sat=0) : c.Tweak(sat=2)))
return vid
}
mode = "raw"
#mode = "gray"
#mode = "saturated"
DoIt(a,mode)It's better than your idea because it runs only the selected filtering.
Thanks :). I'll try it now. Oh btw, since AVISynth works backwards (request frame from return value, which requests frame from last filter, etc), it wouldn't actually run all the filtering anyway, would it? I'd say it'd just ignore the unused parts (in fact it does this cause I have a script that contains a super-slow filter-clip variable and I just don't use it, and I get realtime output).
sh0dan
31st May 2003, 19:38
No - the "if" stuff only returns the filter that is actually being used. So the other filter is never even invoked. The difference is that the "if" is executed when the filter chain is constructed - in contrast to conditional filtering.
Filter chain would be constructed like this:
VFW (Vdub connects here)
|
|--- if (mode = raw) --------------------|
|--- if (mode = grey) --- Greyscale()-----|--- AviSource()
|--- if (mode = sat) --- Tweak() -------|
Only one of the paths will be generated, and actually used, and the "ifs" will not be present in the filter chain.
btw - greyscale() is probably a bit faster than tweak in this particular case - just to be nitpicking.
Guest
31st May 2003, 19:40
@sh0dan
I think he was suggesting that his original idea also wouldn't run all the filter chains, because some results aren't used. I don't know if that is true. Do you?
Anyway, in his script I can't see how Avisynth would know that the results are unused.
sh0dan
31st May 2003, 19:43
@neuron: I actually don't quite get what he's trying to do in the original post, so I though it would better to use your example. :rolleyes:
Sorry if I misunderstood. :o
Originally posted by neuron2
I think he was suggesting that his original idea also wouldn't run all the filter chains, because some results aren't used. I don't know if that is true. Do you?
Actually, I got that from a post from sh0dan. I wouldn't be able to find it back though, cause I don't know what keywords to search for.
Edit: FOUND IT! :D
Originally posted by sh0dan
When vdub requests any given frame from AviSynth, AviSynth will start by requesting the frame from limiter(). Limiter will then need a frame from BilinearResize, and requests this frame by sending off a GetFrame request to the BilinearResize filter. Like this the process goes on until a source is able to deliver the frame.
But anyway, try it :).
input = AVISource("blah.avi")
slow = input.ConvertToRGB32().ConvertToYV12().LanczosResize(2560, 1920).ConvertToRGB32().LanczosResize(input.width, input.height)
fast = input.ShowFrameNumber()
return fast
It should be just as fast as doing AVISource("blah.avi").ShowFrameNumber() .
Oh and btw:Originally posted on AVISynth.org
For error reporting:
AssertEval (string)
But when I try it, I get "There is no function named 'AssertEval'". Is that my fault? :confused:
And btw2: my example in my top post doesn't explain what exactly I'm trying to do. That's why it's just an example ;). But your suggestion works anyway neuron :).
WarpEnterprises
31st May 2003, 21:56
1) If a filter path is not used it is not executed.
2) You are right. AssertEval is documented wrongly. There are two versions of Assert (with and without message string) and AssertEval is only an internal function for this. But Assert() works.
3) Your first version works too. Use Eval():
A=version().greyscale
B=version()
sel="B" # or "A"
return eval(sel) #returns the clip denominated by the string sel
So how do I just give an error? Is there something like ThrowErr(string) ?
/me goes searching through avisynth.org
WarpEnterprises
31st May 2003, 22:44
Assert(false,"Error: always an error")
These things are on syntax.html in the packaged docs.
Please tell us if something is too short or misleading.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.