Wilbert
4th September 2002, 13:38
A while ago I wanted to make a screensaver with AviSynth. I thought that there exists programs which converts avi into scr files, for example this one (http://www.nettrials.com/video-screensaver/avi-screensaver-videos.htm). Besides it is shareware it also cheats because it puts the avi in a seperated directory and uses it.
The zip-file: http://www.geocities.com/wilbertdijkhof/screensaver.zip contains an avi as an example what such a screensaver could like using some new filters of AviSynth. Instead of making a scr-file (maybe there is a good program, anyone?) you can just look at the avi and tell me whether you like it or not. (Sorry for the low quality, 1 Mb is not much :). But now it is even less so I couldn't attach it.) Below is the script that I used. Maybe it is nice to put something on www.avisynth.org about this.
Well, here is the script (first I defined a bunch of general filters):
# Replace the three clips with your own clips. The resolutions and length of the maybe different
# compared to eachother, but the framerate must be the same.
# Maybe you have to add frames to clip1.
clip2=AVISource("F:\models2.avi", false).ConvertToRGB32
clip3=AVISource("F:\lisa_boyles2.avi", false).ConvertToRGB32
clip4=AVISource("F:\phoebe_cates2.avi", false).ConvertToRGB32
clip1=BlankClip(length=3000, width=720, height=576, fps=clip2.framerate, color=$000000)
# general about animate filter: note that in order to apply the animate filter you need to
# feed in with two clips of the same size.
# fade_in: fades in the clip (during the first n frames) starting with two black frames
function fade_in(clip clip, int "n") {
return clip.Blackness(n+2).Dissolve(clip, n)
}
# translation: translates LClip along a straight line on a black background. (centerX,centerY)
# is the center of the first frame of the translation and (center2X,center2Y) is the center
# of the last frame of the translation. LClip starts playing at start_frame (with
# start_frame >= 0 and end_frame >= LClip.framecount).
function translation(clip clip, clip "LClip", int "start_frame", int "centerX", int "centerY", int "end_frame",
\ int "center2X", int "center2Y") {
return Animate(start_frame, end_frame, "layer", clip, LClip, "Add", 255, centerX, centerY,
\ clip, LClip, "Add", 255, center2X, center2Y)
}
# trans_acc: same as the function translation, but LClip is accelerated if m>1, deccelerated if m<1, gives
# the same as translation for m=1.
function trans_acc(clip clip, clip "LClip", int "start_frame", int "centerX", int "centerY", int "end_frame",
\ int "center2X", int "center2Y", float "m") {
end_frame2 = round(m*(end_frame+1)-1)
return Animate(start_frame, end_frame, "translation",
\ clip, LClip, start_frame, centerX-LClip.width/2, centerY-LClip.height/2, end_frame2, center2X-LClip.width/2, center2Y-LClip.height/2,
\ clip, LClip, start_frame, centerX-LClip.width/2, centerY-LClip.height/2, end_frame, center2X-LClip.width/2, center2Y-LClip.height/2)
}
# res: gives a clip which is resized with size (width,height). (centerX,centerY) is the center of
# the resulting clip on a black background.
function res(clip clip, clip "LClip", int "width", int "height", int "centerX", int "centerY") {
LClip=BicubicResize(LClip, width, height)
return layer(clip, LClip, "Add", 255, centerX-LClip.width/2, centerY-LClip.height/2)
}
# resize: resizes LClip to a clip with size (width,height). moves it from center (centerX,centerY)
# to (center2X,center2Y). LClip starts playing at start_frame (with
# start_frame >= 0 and end_frame >= LClip.framecount).
function resize(clip clip, clip "LClip", int "start_frame", int "start_width", int "start_height",
\ int "end_frame", int "end_width", int "end_height", int "centerX", int "centerY",
\ int "center2X", int "center2Y") {
return Animate(start_frame, end_frame, "res", clip, LClip, start_width, start_height, centerX, centerY,
\ clip, LClip, end_width, end_height, center2X, center2Y)
}
# resize_acc: same as the function resize, but LClip is accelerated if m>1, deccelerated if m<1, gives
# the same as resize for m=1.
function resize_acc(clip clip, clip "LClip", int "start_frame", int "start_width", int "start_height",
\ int "end_frame", int "end_width", int "end_height", int "centerX", int "centerY",
\ int "center2X", int "center2Y", float "m") {
end_frame2 = round(m*(end_frame+1)-1)
return Animate(start_frame, end_frame, "resize", clip, LClip, start_frame,
\ start_width, start_height, end_frame2, end_width, end_height, centerX, centerY, center2X, center2Y,
\ clip, LClip, start_frame, start_width, start_height, end_frame, end_width, end_height,
\ centerX, centerY, center2X, center2Y)
}
# circle: gives a clip which is moved along (by varying "t") a circle with center (centerX,centerY)
# with radius "axis" the resulting clip on a black background.
function circle(clip clip, clip "LClip", int "start_frame", int "end_frame", int "centerX", int "centerY",
\ int "axis", float "t") {
return clip.Layer(LClip, "Add", 255, round((centerX-LClip.width/2)+axis*cos(Pi*t*0.5)),
\ round((centerY-LClip.height/2)+axis*sin(Pi*t*0.5)-axis))
}
# spiral: spirals LClip by varying the radius "begin_axis" to "end_axis" when applied to the circle
# function. LClip starts playing at start_frame (with start_frame >= 0 and end_frame >= LClip.framecount).
function spiral(clip clip, clip "LClip", int "start_frame", int "end_frame", int "centerX", int "centerY",
\ int "begin_axis", int "end_axis", float "begin_t", float "end_t") {
return Animate(start_frame, end_frame, "circle",
\ clip, LClip, start_frame, end_frame, centerX, centerY, begin_axis, begin_t,
\ clip, LClip, start_frame, end_frame, centerX, centerY, end_axis, end_t)
}
# spiral_acc: same as the function spiral, but LClip is accelerated if m>1, deccelerated if m<1, gives
# the same as spiral for m=1.
function spiral_acc(clip clip, clip "LClip", int "start_frame", int "end_frame", int "centerX", int "centerY",
\ int "begin_axis", int "end_axis", float "begin_t", float "end_t", float "m") {
end_frame2 = round(m*(end_frame+1)-1)
return Animate(start_frame, end_frame, "spiral",
\ clip, LClip, start_frame, end_frame2, centerX, centerY, begin_axis, end_axis, begin_t, end_t,
\ clip, LClip, start_frame, end_frame, centerX, centerY, begin_axis, end_axis, begin_t, end_t)
}
# resizes the clips to 32xsomething:
clipa=clip2.BicubicResize(32,(32*clip2.height)/clip2.width)
clipb=clip3.BicubicResize(32,(32*clip3.height)/clip3.width)
clipc=clip4.BicubicResize(32,(32*clip4.height)/clip4.width)
# takes the first frame and duplicates it "the number of frames of clip2" times:
clip1_temp=clipa.Trim(0,-1).Loop(clip2.framecount)
clip2_temp=clipb.Trim(0,-1).Loop(clip2.framecount)
clip3_temp=clipc.Trim(0,-1).Loop(clip2.framecount)
# take the three small clips made above and layers them in a triangle with a black background:
C1=clip1.Layer(clip1_temp, "Add", 255, 360-round(0.5*clipa.width), 192-round(0.5*clipa.height)).Layer(clip2_temp, "Add",
\ 255, 360+round(48*sqrt(3))-round(0.5*clipb.width), (192+96+48)-round(0.5*clipb.height)).Layer(clip3_temp, "Add", 255,
\ (360-round(48*sqrt(3)))-round(0.5*clipc.width), (192+96+48)-round(0.5*clipc.height)).Trim(0,clip1_temp.framecount-1)
# similar as above, but with two of the three clips:
C2=clip1.Layer(clip2_temp, "Add", 255, 360+round(48*sqrt(3))-round(0.5*clipb.width), (192+96+48)-round(0.5*clipb.height)).
\ Layer(clip3_temp, "Add", 255, (360-round(48*sqrt(3)))-round(0.5*clipc.width), (192+96+48)-round(0.5*clipc.height)).
\ Trim(0,clip1_temp.framecount-1)
# creates a mask of it since we want to use C2 as a background for clip1 which will be playing and moving:
C2=C2.Mask(C2.Greyscale.Levels(0, 1, 1, 0, 255))
C3=C2.Trim(0,150)
# fades in on C1, this will be the first part of the output clip:
clip_final0=C1.Trim(0,50).fade_in(30)
# the first frame of clip2 will be resize and accelerated to 180xsomething with C3 as background:
clip_final1=C3.resize_acc(clip2.Trim(0,-1).Loop(150), 0, clipa.width, clipa.height,
\ C3.framecount-1, 180, (180*clipa.height)/clipa.width, 360, 192, 360, 288, 0.5)
# clip2 will be resize from 180xsomething to 360xsomething while playing with C2 as background:
clip_final2=C2.resize(clip2, 0, 180, (180*clipa.height)/clipa.width,
\ clip2.framecount-1, 360, (360*clipa.height)/clipa.width, 360, 288, 360, 288)
# the last frame of clip2 is duplicated and will be faded out:
clip_temp=clip_final2.Trim(clip_final2.framecount-1,-1).Loop(100).fadeout2(30)
# ... and is translated/accelerated moving left out of the screen:
clip_final3=C2.trans_acc(clip_temp, 0, 360, 288, clip_temp.framecount-1,
\ 0, 288, 2).Trim(0, 100)
clip_final1 = clip_final1 + clip_final2 + clip_final3
# the first part is similar as above:
C2=clip1.Layer(clip3_temp, "Add", 255, (360-round(48*sqrt(3)))-round(0.5*clipc.width), (192+96+48)-round(0.5*clipc.height)).
\ Trim(0,clip1_temp.framecount-1)
C2=C2.Mask(C2.Greyscale.Levels(0, 1, 1, 0, 255))
C3=C2.Trim(0,150)
clip_final2=C3.resize_acc(clip3.Trim(0,-1).Loop(150), 0, clipb.width, clipb.height,
\ C3.framecount-1, 180, (180*clipb.height)/clipb.width, 360+round(48*sqrt(3)), 192+96+48, 360, 288, 0.5)
clip_final3=C2.resize(clip3, 0, 180, (180*clipb.height)/clipb.width,
\ clip3.framecount-1, 360, (360*clipb.height)/clipb.width, 360, 288, 360, 288)
clip_temp=clip_final3.Trim(clip_final3.framecount-1,-1).Loop(100).fadeout2(30)
# ... and is spiral/accelerated ending in the left corner of the screen:
clip_final4=C2.spiral_acc(clip_temp, 0, clip_temp.framecount-1, 360, 288,
\ 288, 360, 1.0, 2.0, 2).Trim(0, clip_temp.framecount-1).Trim(0, 100)
clip_final2 = clip_final2 + clip_final3 + clip_final4
# the first part is similar as above:
C2=clip1.Trim(0,clip1_temp.framecount-1)
C3=C2.Trim(0,150)
clip_final3=C3.resize_acc(clip4.Trim(0,-1).Loop(150), 0, clipc.width, clipc.height,
\ C3.framecount-1, 180, (180*clipc.height)/clipc.width, 360-round(48*sqrt(3)), 192+96+48, 360, 288, 0.5)
clip_final4=C2.resize(clip4, 0, 180, (180*clipc.height)/clipc.width,
\ clip4.framecount-1, 360, (360*clipc.height)/clipc.width, 360, 288, 360, 288)
clip_temp=clip_final4.Trim(clip_final4.framecount-1,-1).Loop(100).fadeout2(30)
# ... and is spiral/accelerated ending in the right corner of the screen:
clip_final5=C2.spiral_acc(clip_temp, 0, clip_temp.framecount-1, 360, 288,
\ 0, 144, 1.0, 4.0, 2).Trim(0, clip_temp.framecount-1).Trim(0, 100)
clip_final3 = clip_final3 + clip_final4 + clip_final5
return clip_final0 + clip_final1 + clip_final2 + clip_final3
# edit: used v2.04 since Loop is kind of broken in v2.05.
The zip-file: http://www.geocities.com/wilbertdijkhof/screensaver.zip contains an avi as an example what such a screensaver could like using some new filters of AviSynth. Instead of making a scr-file (maybe there is a good program, anyone?) you can just look at the avi and tell me whether you like it or not. (Sorry for the low quality, 1 Mb is not much :). But now it is even less so I couldn't attach it.) Below is the script that I used. Maybe it is nice to put something on www.avisynth.org about this.
Well, here is the script (first I defined a bunch of general filters):
# Replace the three clips with your own clips. The resolutions and length of the maybe different
# compared to eachother, but the framerate must be the same.
# Maybe you have to add frames to clip1.
clip2=AVISource("F:\models2.avi", false).ConvertToRGB32
clip3=AVISource("F:\lisa_boyles2.avi", false).ConvertToRGB32
clip4=AVISource("F:\phoebe_cates2.avi", false).ConvertToRGB32
clip1=BlankClip(length=3000, width=720, height=576, fps=clip2.framerate, color=$000000)
# general about animate filter: note that in order to apply the animate filter you need to
# feed in with two clips of the same size.
# fade_in: fades in the clip (during the first n frames) starting with two black frames
function fade_in(clip clip, int "n") {
return clip.Blackness(n+2).Dissolve(clip, n)
}
# translation: translates LClip along a straight line on a black background. (centerX,centerY)
# is the center of the first frame of the translation and (center2X,center2Y) is the center
# of the last frame of the translation. LClip starts playing at start_frame (with
# start_frame >= 0 and end_frame >= LClip.framecount).
function translation(clip clip, clip "LClip", int "start_frame", int "centerX", int "centerY", int "end_frame",
\ int "center2X", int "center2Y") {
return Animate(start_frame, end_frame, "layer", clip, LClip, "Add", 255, centerX, centerY,
\ clip, LClip, "Add", 255, center2X, center2Y)
}
# trans_acc: same as the function translation, but LClip is accelerated if m>1, deccelerated if m<1, gives
# the same as translation for m=1.
function trans_acc(clip clip, clip "LClip", int "start_frame", int "centerX", int "centerY", int "end_frame",
\ int "center2X", int "center2Y", float "m") {
end_frame2 = round(m*(end_frame+1)-1)
return Animate(start_frame, end_frame, "translation",
\ clip, LClip, start_frame, centerX-LClip.width/2, centerY-LClip.height/2, end_frame2, center2X-LClip.width/2, center2Y-LClip.height/2,
\ clip, LClip, start_frame, centerX-LClip.width/2, centerY-LClip.height/2, end_frame, center2X-LClip.width/2, center2Y-LClip.height/2)
}
# res: gives a clip which is resized with size (width,height). (centerX,centerY) is the center of
# the resulting clip on a black background.
function res(clip clip, clip "LClip", int "width", int "height", int "centerX", int "centerY") {
LClip=BicubicResize(LClip, width, height)
return layer(clip, LClip, "Add", 255, centerX-LClip.width/2, centerY-LClip.height/2)
}
# resize: resizes LClip to a clip with size (width,height). moves it from center (centerX,centerY)
# to (center2X,center2Y). LClip starts playing at start_frame (with
# start_frame >= 0 and end_frame >= LClip.framecount).
function resize(clip clip, clip "LClip", int "start_frame", int "start_width", int "start_height",
\ int "end_frame", int "end_width", int "end_height", int "centerX", int "centerY",
\ int "center2X", int "center2Y") {
return Animate(start_frame, end_frame, "res", clip, LClip, start_width, start_height, centerX, centerY,
\ clip, LClip, end_width, end_height, center2X, center2Y)
}
# resize_acc: same as the function resize, but LClip is accelerated if m>1, deccelerated if m<1, gives
# the same as resize for m=1.
function resize_acc(clip clip, clip "LClip", int "start_frame", int "start_width", int "start_height",
\ int "end_frame", int "end_width", int "end_height", int "centerX", int "centerY",
\ int "center2X", int "center2Y", float "m") {
end_frame2 = round(m*(end_frame+1)-1)
return Animate(start_frame, end_frame, "resize", clip, LClip, start_frame,
\ start_width, start_height, end_frame2, end_width, end_height, centerX, centerY, center2X, center2Y,
\ clip, LClip, start_frame, start_width, start_height, end_frame, end_width, end_height,
\ centerX, centerY, center2X, center2Y)
}
# circle: gives a clip which is moved along (by varying "t") a circle with center (centerX,centerY)
# with radius "axis" the resulting clip on a black background.
function circle(clip clip, clip "LClip", int "start_frame", int "end_frame", int "centerX", int "centerY",
\ int "axis", float "t") {
return clip.Layer(LClip, "Add", 255, round((centerX-LClip.width/2)+axis*cos(Pi*t*0.5)),
\ round((centerY-LClip.height/2)+axis*sin(Pi*t*0.5)-axis))
}
# spiral: spirals LClip by varying the radius "begin_axis" to "end_axis" when applied to the circle
# function. LClip starts playing at start_frame (with start_frame >= 0 and end_frame >= LClip.framecount).
function spiral(clip clip, clip "LClip", int "start_frame", int "end_frame", int "centerX", int "centerY",
\ int "begin_axis", int "end_axis", float "begin_t", float "end_t") {
return Animate(start_frame, end_frame, "circle",
\ clip, LClip, start_frame, end_frame, centerX, centerY, begin_axis, begin_t,
\ clip, LClip, start_frame, end_frame, centerX, centerY, end_axis, end_t)
}
# spiral_acc: same as the function spiral, but LClip is accelerated if m>1, deccelerated if m<1, gives
# the same as spiral for m=1.
function spiral_acc(clip clip, clip "LClip", int "start_frame", int "end_frame", int "centerX", int "centerY",
\ int "begin_axis", int "end_axis", float "begin_t", float "end_t", float "m") {
end_frame2 = round(m*(end_frame+1)-1)
return Animate(start_frame, end_frame, "spiral",
\ clip, LClip, start_frame, end_frame2, centerX, centerY, begin_axis, end_axis, begin_t, end_t,
\ clip, LClip, start_frame, end_frame, centerX, centerY, begin_axis, end_axis, begin_t, end_t)
}
# resizes the clips to 32xsomething:
clipa=clip2.BicubicResize(32,(32*clip2.height)/clip2.width)
clipb=clip3.BicubicResize(32,(32*clip3.height)/clip3.width)
clipc=clip4.BicubicResize(32,(32*clip4.height)/clip4.width)
# takes the first frame and duplicates it "the number of frames of clip2" times:
clip1_temp=clipa.Trim(0,-1).Loop(clip2.framecount)
clip2_temp=clipb.Trim(0,-1).Loop(clip2.framecount)
clip3_temp=clipc.Trim(0,-1).Loop(clip2.framecount)
# take the three small clips made above and layers them in a triangle with a black background:
C1=clip1.Layer(clip1_temp, "Add", 255, 360-round(0.5*clipa.width), 192-round(0.5*clipa.height)).Layer(clip2_temp, "Add",
\ 255, 360+round(48*sqrt(3))-round(0.5*clipb.width), (192+96+48)-round(0.5*clipb.height)).Layer(clip3_temp, "Add", 255,
\ (360-round(48*sqrt(3)))-round(0.5*clipc.width), (192+96+48)-round(0.5*clipc.height)).Trim(0,clip1_temp.framecount-1)
# similar as above, but with two of the three clips:
C2=clip1.Layer(clip2_temp, "Add", 255, 360+round(48*sqrt(3))-round(0.5*clipb.width), (192+96+48)-round(0.5*clipb.height)).
\ Layer(clip3_temp, "Add", 255, (360-round(48*sqrt(3)))-round(0.5*clipc.width), (192+96+48)-round(0.5*clipc.height)).
\ Trim(0,clip1_temp.framecount-1)
# creates a mask of it since we want to use C2 as a background for clip1 which will be playing and moving:
C2=C2.Mask(C2.Greyscale.Levels(0, 1, 1, 0, 255))
C3=C2.Trim(0,150)
# fades in on C1, this will be the first part of the output clip:
clip_final0=C1.Trim(0,50).fade_in(30)
# the first frame of clip2 will be resize and accelerated to 180xsomething with C3 as background:
clip_final1=C3.resize_acc(clip2.Trim(0,-1).Loop(150), 0, clipa.width, clipa.height,
\ C3.framecount-1, 180, (180*clipa.height)/clipa.width, 360, 192, 360, 288, 0.5)
# clip2 will be resize from 180xsomething to 360xsomething while playing with C2 as background:
clip_final2=C2.resize(clip2, 0, 180, (180*clipa.height)/clipa.width,
\ clip2.framecount-1, 360, (360*clipa.height)/clipa.width, 360, 288, 360, 288)
# the last frame of clip2 is duplicated and will be faded out:
clip_temp=clip_final2.Trim(clip_final2.framecount-1,-1).Loop(100).fadeout2(30)
# ... and is translated/accelerated moving left out of the screen:
clip_final3=C2.trans_acc(clip_temp, 0, 360, 288, clip_temp.framecount-1,
\ 0, 288, 2).Trim(0, 100)
clip_final1 = clip_final1 + clip_final2 + clip_final3
# the first part is similar as above:
C2=clip1.Layer(clip3_temp, "Add", 255, (360-round(48*sqrt(3)))-round(0.5*clipc.width), (192+96+48)-round(0.5*clipc.height)).
\ Trim(0,clip1_temp.framecount-1)
C2=C2.Mask(C2.Greyscale.Levels(0, 1, 1, 0, 255))
C3=C2.Trim(0,150)
clip_final2=C3.resize_acc(clip3.Trim(0,-1).Loop(150), 0, clipb.width, clipb.height,
\ C3.framecount-1, 180, (180*clipb.height)/clipb.width, 360+round(48*sqrt(3)), 192+96+48, 360, 288, 0.5)
clip_final3=C2.resize(clip3, 0, 180, (180*clipb.height)/clipb.width,
\ clip3.framecount-1, 360, (360*clipb.height)/clipb.width, 360, 288, 360, 288)
clip_temp=clip_final3.Trim(clip_final3.framecount-1,-1).Loop(100).fadeout2(30)
# ... and is spiral/accelerated ending in the left corner of the screen:
clip_final4=C2.spiral_acc(clip_temp, 0, clip_temp.framecount-1, 360, 288,
\ 288, 360, 1.0, 2.0, 2).Trim(0, clip_temp.framecount-1).Trim(0, 100)
clip_final2 = clip_final2 + clip_final3 + clip_final4
# the first part is similar as above:
C2=clip1.Trim(0,clip1_temp.framecount-1)
C3=C2.Trim(0,150)
clip_final3=C3.resize_acc(clip4.Trim(0,-1).Loop(150), 0, clipc.width, clipc.height,
\ C3.framecount-1, 180, (180*clipc.height)/clipc.width, 360-round(48*sqrt(3)), 192+96+48, 360, 288, 0.5)
clip_final4=C2.resize(clip4, 0, 180, (180*clipc.height)/clipc.width,
\ clip4.framecount-1, 360, (360*clipc.height)/clipc.width, 360, 288, 360, 288)
clip_temp=clip_final4.Trim(clip_final4.framecount-1,-1).Loop(100).fadeout2(30)
# ... and is spiral/accelerated ending in the right corner of the screen:
clip_final5=C2.spiral_acc(clip_temp, 0, clip_temp.framecount-1, 360, 288,
\ 0, 144, 1.0, 4.0, 2).Trim(0, clip_temp.framecount-1).Trim(0, 100)
clip_final3 = clip_final3 + clip_final4 + clip_final5
return clip_final0 + clip_final1 + clip_final2 + clip_final3
# edit: used v2.04 since Loop is kind of broken in v2.05.