Log in

View Full Version : ConditionalReader not working right?


Xzyx987X
26th December 2005, 04:51
Here is the script I wrote for encoding a DVD I have:

LoadPlugin("C:\Program Files\AviSynth2\plugins\MPEGDecoder.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\LeakKernelDeint.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\Decomb521.dll")
LoadPlugin("C:\Program Files\AviSynth2\plugins\ffavisynth.dll")

global minimalFiltering = false

MPEGSource("D:\Rip\VTS01-PGC01.VOB")

Telecide(order=1, guide=3, post=1, vthresh=10, show=false, hints=true)

LeakKernelDeint(order=1, threshold=0, sharp=true)

Decimate()

converttoyuy2()

ConditionalReader("MinimalFiltering.txt", "minimalFiltering", false)

minimalFiltering ? ffdshow(preset="AVS_M") : ffdshow(preset="AVS")

Crop(8, 4, -20, 0, align=false)

Limiter()I'm having a weird problem though, where my conditional statements don't seem to be working right. For some reason only the first condition is triggered on the line that selects which ffdshow filter setting to use. I tried swapping them back and forth, but it's always the one to the left of the ":" that's used. I would've thought that was because ConditionalReader wasn't selecting the correct values, but when I turned on show it does seem to be giving the values I expected. I'm not exactly sure what else the problem could be, so does anyone here know?

stickboy
26th December 2005, 07:33
I can't explain why it always follows the true-branch, but I think you might have a fundamental (but common) misunderstanding of how ConditionalReader works.

AviSynth does not re-evaluate your entire script on every frame to satisfy the whims of ConditionalReader. An AviSynth script is evaluated only once, when it is initially loaded. Therefore, the conditionalminimalFiltering ? ffdshow(preset="AVS_M") : ffdshow(preset="AVS")is not re-evaluated on every frame.

How does ConditionalReader work, then? ConditionalReader can be used only with other functions that are designed to work with it--functions that are designed to vary their behavior for every frame and know to retrieve global variables from the environment continuously--such as ScriptClip, FrameEvalute, Overlay, etc.

stickboy
26th December 2005, 07:54
BTW, I'll add that if what you want to do is to apply some filter to a bunch of pre-determined frames, a better way to do it is to use ReplaceFramesSimple from my RemapFrames plugin (http://www.avisynth.org/stickboy/):
c = ffdshow(preset="AVS")
m = ffdshow(preset="AVS_M")
ReplaceFramesSimple(c, m, "MinimalFiltering.txt")The file format that ReplaceFramesSimple expects is different from that of ConditionalReader, though.

sh0dan
26th December 2005, 11:29
To be able to read conditional variables, you need to use ConditionalFilter, ScriptClip or FrameEvaluate or similar. Your script evaluates "MinimalFiltering" ONCE - and that is when the filter is created. Also the variable should be read after the conditional filter (remember the graph works backwards)

Your filter should look something like this:


ontrue = ffdshow(preset="AVS_M")
onfalse = ffdshow(preset="AVS")
ConditionalFilter(ontrue, ontrue, onfalse, "minimalFiltering", "==", "true")
ConditionalReader("MinimalFiltering.txt", "minimalFiltering", false)