Log in

View Full Version : Code help for AVISynth Transitions


makoto916
6th May 2004, 22:08
Greetings everyone! Long time lurker, first time poster. ^_^

I'm having a bit of trouble trying to figure out how to make a function and am in need of some assistance.

What I'm trying to do is make a function to enable transitions between a series of videos. Here's what I have:

t1=AVISource("trans_swirl.avi")
v1=AVISource("videotest1.avi")
v2=AVISource("videotest2.avi")

v1a=v1.trim(0,v1.framecount-91)
v1b=v1.trim(v1.framecount-90,0)
v2a=v2.trim(0,90).Mask(t1)
v2b=v2.trim(91,0)

v1a+Layer(v1b,v2a, "add")+v2b

The transition is exactly 90 frames and all video sources will always be greater than 90 frames so I'm comfortable with the assumptions the code makes.

I've put the transition online ('http://www.blainehelmick.com/avisynth/trans_swirl.avi') if you'd like to download it. I used MS MPEG-4 v2 as the codec because it supports RGB32 with Alpha, creates a very small file, decodes quickly, and just about everyone has it.

Making the transition file was simple, I just used AfterFX to create a blend between a black and white square. Then used the Mask function of AVISynth to assign this file to 90 frames of my second video. When combined with Layer and put back together it creates a perfect transition between my two video sources. This isn't fancy, but it works.

So here's the code question. How do I create a function that simplifies this process? If I had 30 sources persay that I wanted to create transitions between how could I create a peice of code that automates the process of cutting, and mask assignemnt?

Ultimately, I'm trying to automate this process by creating a DOS batch that reads from a CSV text file and assembles an AVS script based upon instructions written into the CSV. I currently use the DOS Batch and CSV method for several other automated scripts, but I'm having difficulty thinking of a way to do it here.

What I'd really like is something along these lines:

t1 = Transition 1
t2 = Transition 2
t3 = Transition 3
v1 = video 1
v2 = video 2
v3 = video 3
v4 = Video 4

function Transition(whatever variables) {
happy code
}

Transition(v1,t1,v2,t2,v3,t3,v4,t1,v5,t2,v6,t3,etc,etc)

I will have an unkown number of video sources that I will need to create transitions for. So I can't have anything fixed to a specifc number.

To acheive this same thing now I have to assemble my video sources in Premiere and add the transitions. Natrually this is a royal pain but so would be typing the script every time if I can't come up with an automated system. Any help is greately appreciated.