I have a bunch of individual files that I want to each run through Avisynth. However, an AVS file can only create one video. As far as I know, there is no way to declare a variable's value from the command line.
I know that you can probably create a script that generates a bunch of AVS files and then somehow convert each AVS file to a video. However, since Avisynth is a scripting system, this seems kind of complicated. There must be some way to run different videos through a script, right?
What is the best way to do this? Thanks in advance.
Another answer to this question would be letting the AviSynth script get its own name to point the file you want to process. If you want the script to work on
movie.mp4
, you can rename it tomovie.mp4.avs
. The script would be something like:You can do the same operations on different videos just renaming the script (provided the videos and the
.avs
are in the same folder). Uncomment the next-to-last line to see what I mean.It seems that each AviSynth script represents a single video.
To workaround this (in a similar way to marapet's answer), I've also developed a
.BAT
file whereby you can drag-and-drop video files upon it and an AVS file is created for each one and the path to the video is automatically inserted.I think this is a bit more flexible as it uses placeholders in the script. It can also optionally run ffmpeg (or whichever command you prefer) on each one to render and encode the final result.
Setup Instructions
.BAT
file.BAT
calledAviSynth Templates
Create your master AVS script (e.g.
master.avs
) in this subfolder and use the placeholder[CLIP]
wherever you want the video path to be injected. (You can also use[CLIP-NO-EXTENSION]
to exclude the file extension if you have extra assets related to that video.)Drag and drop video files onto your BAT to create a customised AVS file for each one. If you drop the same video files onto the BAT again the AVS will be overwritten with a new version.
Create AVS files.bat
I've never found a way to pass a command line parameter directly to a AVS script. Generating scripts on the fly is the only way I was able to get it working.
I know this is not the answer you're looking for - nevertheless two approaches for generating scripts:
Template script
I use this when I have a AVS script where the only parameter which changes is the source input file.
I have a script
template.avs
which expects a variable (v
) containing the full path of the source video. A batch script then simply prepends the line with the variable for each video file, similar to this:This allows me to simply drag-and-drop several source videos onto the batch.
Import
Using the Import instruction, it is possible to externalize all the variable declarations into its own script.
This is useful when the template AVS script expects multiple variables.