PDA

View Full Version : A perl script to parse avisynth .avs file?


fizzybrain
17th October 2009, 16:10
Hello,

Does anyone know of a perl script/module/fragment to read and parse a .avs file? I have written animation software which generates frames and .avs file to string them all together. Now as a development of that I want to read the .avs file I've already created to assist with editing the frames I have made.

My .avs file is very simple - it just sets up sequences and pauses and then adds them all together. It looks something like this ("..." = about a hundred similar entries cut out):
===============
clip_1 = ImageSource("scale3d_21_2009-10-16_20-24-09_%04d.png", start=0, end=20, fps=5,pixel_type = "rgb24")
pause_1=ImageSource("scale3d_21_2009-10-16_20-24-09_0020.png", fps=5,pixel_type = "rgb24").trim(1,15)
clip_2 = ImageSource("scale3d_21_2009-10-16_20-24-09_%04d.png", start=21, end=71, fps=5,pixel_type = "rgb24")
pause_2=ImageSource("scale3d_21_2009-10-16_20-24-09_0071.png", fps=5,pixel_type = "rgb24").trim(1,5)

...

clip_75 = ImageSource("scale3d_21_2009-10-16_20-24-09_%04d.png", start=1057, end=1067, fps=5,pixel_type = "rgb24")
pause_75=ImageSource("scale3d_21_2009-10-16_20-24-09_1067.png", fps=5,pixel_type = "rgb24").trim(1,2)
clip_76 = ImageSource("scale3d_21_2009-10-16_20-24-09_%04d.png", start=1068, end=1078, fps=5,pixel_type = "rgb24")
pause_76=ImageSource("scale3d_21_2009-10-16_20-24-09_1078.png", fps=5,pixel_type = "rgb24").trim(1,2)
clip_77 = ImageSource("scale3d_21_2009-10-16_20-24-09_%04d.png", start=1079, end=1089, fps=5,pixel_type = "rgb24")
pause_77=ImageSource("scale3d_21_2009-10-16_20-24-09_1089.png", fps=5,pixel_type = "rgb24").trim(1,2)


+clip_1+pause_1+clip_2+pause_2+clip_3 ... +clip_76+pause_76+clip_77+pause_77
======================

It's a fairly trivial task, and I'm sure I can write something for my own needs, but I just thought that if anything already exists then it would make sense to use it.

Share and Enjoy

neuron2
17th October 2009, 16:17
Your stated requirements for the perl script are too vague to allow any meaningful answer.

fizzybrain
17th October 2009, 16:35
For my purposes I just want to read the .avs script, find out the image sources for each clip (or pause), what the start frame is of each clip, what the finish frame is , what the values in "trim" are, that sort of thing. Basically, find all the labels and values in the
.avs script.
I *can* write this myself, but I just thought that someone might have written a nice all-inclusive parser that would would read *any* .avs script and return the variables in code, as that would a) save me a bit of time, and b) be useful in the future should my code get more complex.