Log in

View Full Version : TRANSITION and Emulating a FOR...IN...DO loop


dosdan
17th August 2005, 01:45
I want to use Select(...) to load a number of different numbered stills to form a number of slideshow sequenced for insertion within my clip. I'm using Transition to move from one to the next. Here is what I've done for just 2 stills:


LoadPlugin("G:\AviSynth 2.5\plugins\avisynth_c.dll")
LoadCPlugin("G:\AviSynth 2.5\plugins\Transition.dll")

function LoadImage(string filename) {
ImageSource("K:\!Kiribati Independence Combined\"+filename+".bmp", 0, 0, 25)
Loop(100) # 4secs @ 25fps
return last
}

clip1 = LoadImage("01")
clip2 = LoadImage("02")

tframes = 50 # Length of transition
pattern = "WipeRight"
smooth = 7
sequence = Transition(clip1, clip2, tframes, pattern, smooth)

return (sequence)



I can do it for 2 clips but how do I load and combine longer sequences? Transition works with two clips at a time so there need to be some logic to perform a S1 -> S2 -> S3 rather than a S1->S2 + S2->S3 i.e. maintain the same display length for each still. Maybe every part in the transition command, expect the first and the last, needs to be half the image display duration (T) duration e.g. for 3 stills: S1(1/2T) + S1(1/2T)->S2(1/2T) + S2(1/2T)->S3(1/2T) + S3(1/2T)

How to loop this so I could just specify LoadSequence(01,02,03)?

stickboy
17th August 2005, 02:10
If you need a looping construct, write a recursive function.

esby
17th August 2005, 22:04
There is something I don't get in the initial post.
Why don't you just do something like that:


LoadPlugin("G:\AviSynth 2.5\plugins\avisynth_c.dll")
LoadCPlugin("G:\AviSynth 2.5\plugins\Transition.dll")

function LoadImage(string filename) {
return ImageSource("K:\!Kiribati Independence Combined\"+filename+".bmp", 0, 100, 25)
}

tframes = 50 # Length of transition
pattern = "WipeRight"
smooth = 7

clip1 = LoadImage("01")
clip2 = LoadImage("02")
clip3 = LoadImage("03")
clip4 = LoadImage("04")
(...)
(copy & paste; and change...)

sequence = clip1
sequence = Transition(sequence, clip2, tframes, pattern, smooth)
sequence = Transition(sequence, clip3, tframes, pattern, smooth)
sequence = Transition(sequence, clip4, tframes, pattern, smooth)
(...)
return sequence



Now if I assume you have 4 images in your example:
01.bmp ,02.bmp ,03.bmp ,04.bmp

you could also do:


LoadPlugin("G:\AviSynth 2.5\plugins\avisynth_c.dll")
LoadCPlugin("G:\AviSynth 2.5\plugins\Transition.dll")

function applyTransition(clip src, int pos) {
part1 = clip.trim(0,pos)
part2 = clip.trim(pos+1,0)
tframes = 50 # Length of transition
pattern = "WipeRight"
smooth = 7
return Transition(part1, part2, tframes, pattern, smooth)
}

src = ImageSource("K:\!Kiribati Independence Combined\%0d.bmp", 0, 4, 25)
src = src.selectEvery(1,100)

src = src.applyTransition(100)
src = src.applyTransition(200)
src = src.applyTransition(300)
# if you have 4 images, you should have 3 transitions

return src


I don't think I am wrong, since I am not at home,here, but it should work for what it seems you want to do.

esby

dosdan
18th August 2005, 02:25
Thanks for the reply. I'll try it when I get home. I was hoping for a "smart" version that automatically accommidated a variable number of filenames (stills)but I think to would take too long to perfect it - I'm under pressure to start supplying DVDs by the coming weekend.

Last night, I started using the freeware Slide Show Movie Maker. http://joern-thiemann.de/

It has a a 2GB AVI size limit which I don't think will be a problem for me as my sequences are not that long. (The 30-photo sequence will be over that size limit unless I use Xvid compression, or I'll just make a few, shorter, uncompressed sequences). I prefer the wipe in TRANSITION over SSMM but it's quite an advantage being able to use a GUI to tag the stills I want to load and then easily shuffle them around in the preview sequence - I'm using stills from 3 sources with 3 different naming conventions). WMP keeps showing me an AVI chunck view when I load "soundless" AVIs produced by SSMM telling me that they are interleaved incorrecty and strongly advising me to reinterleave them before comitting them to slow media like a CD-ROM but I should be easily able to handle this with KillAudio() in AviSynth.

mg262
18th August 2005, 22:36
Script functions can't accommodate a variable number of arguments. (I asked about this recently, so I'm sure of that answer!)

stickboy
19th August 2005, 06:39
You can fake it by passing all the arguments as a single string and then parsing it.

Strings as a poor-man's array (http://forum.doom9.org/showthread.php?p=367841#post367841)