Log in

View Full Version : ConditionalReader help needed


Peter1234
17th September 2005, 23:40
I am using AviSynth in a batch file and I want the frame width and height to be variables that can be set external to AviSynth. I have tried to use ConditionalReader to do this, but can not get it to work. My AviSynth lines are:

width=640
height=480
ConditionalReader(frame.txt, width, height )
BilinearResize(width, height)

The frame.txt file is a notepad text file saved as ANSI text and is:

Type int
Default 480
320 240

The frame.txt file is in the same folder as AviSynth. When I run the batch file I get the following error message:

avis [error]: unsupported input format <DIB > 0could not open input file ‘script.avs’

Everything works correctly if I delete the following script line:

ConditionalReader(frame.txt, width, height ).

I have tried many different variations, but none of them worked. Can someone tell me what I am doing wrong? If there is a better way to use variables in AviSynth, please let me know. Thanks for any help.

foxyshadis
18th September 2005, 05:03
"avis [error]: unsupported input format <DIB > 0could not open input file ‘script.avs’"

This means avisynth reverted to dumping the frames to display an error message, but x264 won't import that. Open it in vdub to see the error.

In your case I can already tell you what the error is: You can only have one variable per conditional file, the file format is "frame# value". Use two calls/files if you need two variables. (And I believe the filename has to be quoted as well.) You really need to read the documentation for this filter, because it's not used like normal filters.

http://www.avisynth.org/ConditionalReader

Peter1234
18th September 2005, 05:39
@foxyshadis:
Thank you for your help. I have read the documentation and all the search results, but it still is not clear. Are frame nuimbers required if I want to apply the variable to all frames?

EDIT:

I did get the following lines to work

BilinearResize(width, height)
ConditionalReader("width.txt", "width")

with this text file

Type int
Default 480
R 1 300 320


Thanks for pointing out that only one variable could be used. I think that was my problem before.

EDIT2:

Thanks again for your help. I have it working now. I used 2 text files width.txt and height.txt both as follows

Type int
Default 10
320

and the following AVS lines

ConditionalReader("width.txt", "width")
ConditionalReader("height.txt", "height")
BilinearResize(width, height)

Peter1234
18th September 2005, 06:46
I spoke too soon. I am not getting any errors, but the variables are not being set. So I still need help.

sh0dan
18th September 2005, 10:28
@Peter: First off, I think you start up with something a lot simpler, so you get your AviSynth basics a bit better. Your script has many problems:

* Frame size cannot change at random frames.
* Conditional values can only be used in Conditionalfilter, Scriptclip and FrameEvaluate.
* I don't see a source in your script.
* You need quotes around filenames.

foxyshadis
18th September 2005, 11:21
If you read the manual, you'll notice that ConditionalReader goes after the functions you want to use the variables in, and that those functions have to be wrapped in a Scriptclip(). It kinda breaks your brain. If you really want different framesizes, you'll have to crop or add borders to even them all out too.

You might want to peruse the examples at http://www.avisynth.org/ConditionalFilter , but they get complex quickly. If you have only a few ranges or frames, it'd be much easier to chain trims to do it manually. I played with it for a few nights but I had to take another approach to solve my problem.

mg262
18th September 2005, 11:44
Personally I would have the batch file create a simple AVISynth script from scratch (using the echo command), with the exact numbers written into the script changed according to the relevant batch parameters. Then the batch file could call whatever program with that script.

I have a few batch files of the kind I described lying around, and if you want I'll post one up later. But as sh0dan says, you should get a few simple scripts working before you do anything else.

Peter1234
18th September 2005, 18:21
Thanks to all for your help. I am just learning how to use batch files, and I was trying to see if there was some way to set up a batch file to run different configurations of an AviSynth script overnight. I guess the best thing to do is use a separate script for each variation.

mg262
18th September 2005, 18:47
For now, for you, probably the best thing to do is to create one script file per configuration you're interested in, and then use VirtualDub to queue them all up and run overnight. (When you select save, there is an option to add it to job control rather than running immediately. Queue them all up like this, and then find Job Control in the menus..)