Log in

View Full Version : Use custom variable with ConditionalReader()


Rob105
10th June 2023, 13:03
How to make this work so box_width is read from box_width.txt right now its fixed on value 70 regardless what ConditionalReader outputs 130.

v1 = colorbars(1920,1080).converttoyuy2()

box_width = 70
#Make box overlay
box = BlankClip(width=box_width, height=130, color=$000000).AddBorders(5,5,5,5,color=color_white)

#place overlay in video
Overlay(v1, box, x=740, y=600)

ConditionalReader("C:\Users\User\Downloads\AVISynth\box_width.txt", "box_width", true)

Gavino
11th June 2023, 17:41
ConditionalReader() is for setting the value of a variable on a per-frame basis, so that the variable can be used inside another run-time filter such as ScriptClip().
But here you are using the variable box_width only to set the width of the blank clip, which happens at compile-time, before any frames are read.

You can get the effect you want by putting the required value (eg 130) as the only contents of the file and setting the variable by adding
box_width = Import("box_width.txt")
at some point before the call to BlankClip().
(And of course in addition removing the call to ConditionalReader()).