Log in

View Full Version : screensavers


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.

Defiler
4th September 2002, 14:18
Wow. Now THAT is a script.

sh0dan
4th September 2002, 14:53
@WIlbert: Have you ever been mentally tested? :D

Man, this is wicked! :cool:

BTW, loop is fixes is the latest CVS build.

Koepi
4th September 2002, 15:25
scr is just renamed exe.

So, you just need to write a "media player" which plays your avs and statically links your avis and avisynth (to make it general).

I hope this helps...
Regards,
Koepi

Wilbert
4th September 2002, 15:38
scr is just renamed exe.

So, you just need to write a "media player" which plays your avs and statically links your avis and avisynth (to make it general).

Sorry, I don't understand what you are saying here. Can you explain a little bit more, how do I write a "media player" which plays my avs?

Koepi
4th September 2002, 15:48
Uh sorry, I thought you were a programmer :-/

Well, then forget about what I wrote.

Really sorry.

Regards,
Koepi

Didée
4th September 2002, 15:51
Wow. Now THAT is a script.
Yes, indeed ;)
@WIlbert: Have you ever been mentally tested?

LOL!

Okay, my longest AVS was only half that length ...

But ... did anyone of you ever dive into POV-RAY?

I did, excessively. You wont´t believe how *HUGE* scripts can get ...

[Didée is throwing everything away, hurrying home, to try Wilbert´s script]

Marc FD
4th September 2002, 19:30
Originally posted by Koepi
scr is just renamed exe.
So, you just need to write a "media player" which plays your avs and statically links your avis and avisynth (to make it general).


No. it's not as simple : screensavers need to respond to special WinAPI calls.

Uh sorry, I thought you were a programmer :-/

I am one :devil:

@Wilbert

it's Xmas :)

i attached a screen saver i just coded. it would load the file scr.avs (in the same folder), then play it in fullscreen. Sound support.
no DShow/DirectX hardware acceleration, so it's not very very fast.
NOTE : the clip is resized to current desktop size (not very nice)

but i'm totally ill (i have currently 40 deg fever) so i can't code much.

enjoy ;) (i really hope it would work)

PS : I don't now at all how to register a screen saver : this is a regular .scr file, but i dunno how windows would recognise it ...
i leave it to you ;)

Marc FD
4th September 2002, 19:31
Originally posted by Koepi
scr is just renamed exe.
So, you just need to write a "media player" which plays your avs and statically links your avis and avisynth (to make it general).


No. it's not as simple : screensavers need to respond to special WinAPI calls.

Uh sorry, I thought you were a programmer :-/

I am one :devil:

@Wilbert

it's Xmas :)

i attached a screen saver i just coded. it would load the file scr.avs (in the same folder), then play it in fullscreen. Sound support.
no DShow/DirectX hardware acceleration, so it's not very very fast.
NOTE : the clip is resized to current desktop size (not very nice)

but i'm totally ill (i have currently 40 deg fever) so i can't code much.

enjoy ;) (i really hope it would work)

PS : I don't now at all how to register a screen saver : this is a regular .scr file, but i dunno how windows would recognise it ...
i leave it to you :)

vidiot
4th September 2002, 21:26
Originally posted by Didée


But ... did anyone of you ever dive into POV-RAY?

[Didée is throwing everything away, hurrying home, to try Wilbert´s script]

Yes, - me!
Thats why I suggest making a CAD Kernel out of POVRAY after suggesting to make a "full-fledged video editor gui" for the "Video-Kernel" Avisynth.

@MarcFD:
40°C fever?
Don´t you think it´s time to turn off that da$n thing in front off you and go to bet to get your health back? ;)

And not be be to much OT:
The script is very nice!!
But if you like even longer scripts, take a look at vcdhelp
"How to edit with Avisynth"

http://www.vcdhelp.com/forum/userguides/99389.php
really amazing!

Wilbert
5th September 2002, 09:27
i attached a screen saver i just coded. it would load the file scr.avs (in the same folder), then play it in fullscreen. Sound support.
no DShow/DirectX hardware acceleration, so it's not very very fast.
NOTE : the clip is resized to current desktop size (not very nice)


Cool! I will try it if I see your attachment :)

But if you like even longer scripts, take a look at vcdhelp
"How to edit with Avisynth"

http://www.vcdhelp.com/forum/userguides/99389.php
really amazing!

Yeah indeed, very nice ... (although they used the possibilities of v1.06/v1.07)

Wilbert
6th September 2002, 17:33
@Marc FD,

Please ..., let me also enjoy Xmas. Can you attach it please?

Marc FD
6th September 2002, 19:12
oups, it didn't attach (and i checked !!)

i tried a second time here.
hope it works :)

Wilbert
11th September 2002, 12:18
It doesn't work. I have screensaver.avi, screensaver.avs and your file in the same dir, and when "testing" it I got the following message:

(attached a jpg)

Marc FD
11th September 2002, 12:58
Originally posted by Marc FD

the file scr.avs

and _not_ screensave.avs

please try again :)

Wilbert
12th September 2002, 12:12
I did was you said, I even moved scr.avs and avsscr.scr to the system-dir. But when I tested it I got the same message (Win98SE: athlon and pentium).

Marc FD
12th September 2002, 16:05
strange....
worked flawlessly for me.
but i had 40 deg fever... maybe an hallucination.

i'll check it ;)