Log in

View Full Version : Scripting novice to be grateful for any help with an Import question.


hinsdale1
1st October 2011, 17:31
My script is intended to automate the process of splicing (with transitions, etc) 40-50 small clips that each have their own title overlays etc.

Is it possible to import data via a Tab or Semicolon delineated text file that can be assigned dynamically to the relevant variables for each clip?

For example:

Data.txt
-----------------------------------
;clip;file;title;titlesub;year;start;end;TW;LW

R1;"D:\Test Videos\vacation-aa.mkv";"Grand Caymen";"Thanksgiving - Exclusive Resorts";"2009";1251;1750;29;11
R2;"D:\Test Videos\vacation-b1.mkv";"Puerta Viarta";"January - Christi's 40th";2010;1999;2250;2;1

that will somehow result in the following variables being assigned:


file_R1 = DirectShowSource("D:\Test Videos\vacation-aa.mkv")
title_R1 = "Grand Caymen"
titlesub_R1 = "Thanksgiving - Exclusive Resorts"
year_R1 = "2009"
start_R1 = 1251
end_R1 = 1750
TW_R1 = 29
LW_R1 = 11


file_R2 = DirectShowSource("D:\Test Videos\vacation-b1.mkv")
title_R2 = "Puerta Viarta"
titlesub_R2 = "January - Christi's 40th"
year_R2 = "2010"
start_R2 = 1999
end_R2 = 2250
TW_R2 = 2
LW_R2 = 1



Any guidance would be greatly appreciated.. my novice head is hurting a little bit.

IanB
2nd October 2011, 02:09
With enough cunning you could probably do this in Avisynth using ConditionalReader() with ScriptClip() and friends, but it would be so much easier to use a more suitable tool to just generate execute ready Avisynth scripts on the fly.

From the little information provided I might be reaching for a quick Perl script to parse the semicolon delimited arguments and emit canned chunks of Avisynth script.

@fields = split /;/, $line;

It mostly depends on what you have available and what you are comfortable with. Others have used cmd.exe batch scripts, Visual Basic code, AWK, Emacs macros. Gvim macros, custom script composition applications, etc. I have even used VBscript from within Excel because that was all that PC had installed.

Trickiest bit usually is emitting quotes or brackets into the Avisynth script because your tool likes quotes and brackets for it's own syntax. Things like backslash, \, or Chr$(34) are your friends.

...
printf "DirectShowSource(\"%s\")\n", file;
printf "Trim(%d, %d)\n", start, end;
printf "SubTitle(\"%s\", first_frame=%d, last_frame=%d, size=30)\n", title, ts, te;
....

hinsdale1
3rd October 2011, 23:16
Thanks for giving some of your valuable time to reply! I was hoping it was something simple that i was just missing. But instead I have handled the formating of the variable data directly through Excel as one of the methods you suggested. After you helped me solve this issue however, I have encountered another problem I had not anticipated in the script.

When working on all of the testing, i was using only 3-4 video clips. When going full production with 40-50 clips I am encountering many memory issues. I didnt realize that it would open two(2) Haiai Splitters (not sure why two) and a Fdshow Video decoder for EACH of the 40-50 clips. This is causing a memory error when loading into MeGUI or even just VDub.

Are there any tricks anyone could help me with that help solve the memory problems? Spit audio and video into seperate scripts? Is there a way to process the scripts that doesnt load everything into RAM? I am a little dumfounded.. my novice head is still hurting a bit. I saw the new Prune addon does something similar without loading everything but I dont think I can use all the different transition effects with this method.


Thanks for any help anyone can provide.