Log in

View Full Version : AviSynth to only play files


Deckard2019
18th October 2005, 10:59
I wish to use AviSynth to only play files, in any DirectShow player.
I want to add playing features, without altering source file (subtitles, cropping, etc ...).
Is it a good idea ?

Is there a way to change AVS script behaviour on-the-fly ?

Thank you.

foxyshadis
18th October 2005, 11:16
You can use ffdshow for this, if that's your decoder. Just open the config and enable avisynth, the put your custom commands in there (with profile if need be). You can open or save a file from there too. Many of the filters avisynth gives are available right in ffdshow's config, but you have the choice.

Otherwise I think your options are limited to creating and opening avisynth files with directshowsource("file") manually.

gzarkadas
18th October 2005, 15:43
I wish to use AviSynth to only play files, in any DirectShow player.
I want to add playing features, without altering source file (subtitles, cropping, etc ...).
Is it a good idea ?

Is there a way to change AVS script behaviour on-the-fly ?

Thank you.
You cannot change AVS script behaviour on the fly, but you can use the Import() (http://www.avisynth.org/Import) statement and use two scripts:

an input one that will assign values to the (global (http://www.avisynth.org/ScriptVariables)) parameters that modify the script's behaviour,
a 'main program' one that will do the actual processing based on the value of the global parameters

An abstract example is provided below:

Input script (lets say "input.avs", in the same folder as the main script)

global frame_start=100
global frame_end=6400
global cropw = 640
global croph = 480

Main script

Import("input.avs")
Trim(frame_start, frame_end)
Crop(0, 0, cropw, croph)
...
# other commands

You will then need a second script language to create the input script on the fly with the parameters you want (for example a windows batch file, windows script host or python (http://www.python.org/)).
The most tricky part is to construct a DirectShowSource("the filename") sentence. You may try this example batch file as a place to begin with (the batch has to be in the same folder as the .avs files):

REM Set any global variables wanted
REM first line must have > to overwrite the target file, next lines >> to append to it

echo global frame_start = 100 > input.avs
echo global frame_end = 6400 >> input.avs
echo global cropw = 640 >> input.avs
echo global croph = 480 >> input.avs

REM Write all video files inside this folder to script - if target extension is .mpg, etc. modify line below
REM Since coding this way overwrites the 'last' implicit variable there has to be only one file inside this folder

for %%f in (*.avi) do echo DirectShowSource("%%f") >> input.avs

Alternatively, if you are only using a small number of parameter sets you can do the following (its manual and thus a bit more time consuming):

Store each set inside a different .avs file
Put all input files inside a (template) folder
For the clip filename use a constant name (say "play.avi"); you may then incorporate it to the main script
For each file you want to play copy the file to a folder, rename it to "play.avi", copy the right input file, rename it to "input.avs", copy the main script and run it.

The above are useful if you are doing most of the time the same staff (for example resizing or cropping to same dimensions, or trimming-out speficic frames from start or end) with only some parameters changed.