Blog
Lil Avisynth Script
Date: 21/5/2008
I was playing around with AviSynth yesterday and came up with a cool little script that makes a movie out of a series of images such in the style of the Apple photo screen saver, i.e. the photos are slowly zoomed for a number of seconds and then cross faded to the next photo.

# this is the output size
x = 800
y = 600

# This is the length of each photo in frames...
seg_len = 150
# This is the length of the cross fade in frames...
seg_fade = 20


function Asp(clip c1, float a)
{
	c1a = float(c1.Width) / float(c1.Height)
	c1x = c1a < a ? c1.Width : c1.Height * a
	c1cx = c1x < c1.Width ? (c1.Width - c1x) / 2 : 0
	c1y = c1a < a ? c1.Width / a : c1.Height
	c1cy = c1y < c1.Height ? (c1.Height - c1y) / 2 : 0
	return Crop(c1, int(c1cx), int(c1cy), -int(c1cx), -int(c1cy))
}

a = float(x) / float(y)
c1 = Asp(ImageSource("image1.jpg", 0, seg_len), a)
c2 = Asp(ImageSource("image2.jpg", 0, seg_len), a)
c3 = Asp(ImageSource("image3.jpg", 0, seg_len), a)
out = Dissolve( \
			Animate(0,seg_len, "LanczosResize", \
				c1, x, y, 0.0,  0.0,  c1.Width, c1.Height, \
				c1, x, y, 32.0, 32.0, c1.Width-64.0, c1.Height-64.0), \
			Animate(0,seg_len, "LanczosResize", \
				c2, x, y, 32.0,  32.0,  c2.Width-64.0, c2.Height-64.0, \
				c2, x, y, 0.0, 0.0, c2.Width, c2.Height), \
			Animate(0,seg_len, "LanczosResize", \
				c3, x, y, 0.0,  0.0,  c3.Width, c3.Height, \
				c3, x, y, 32.0, 32.0, c3.Width-64.0, c3.Height-64.0), \
				seg_fade)

return out


I could easily see this being used to generate nice slide shows for a DVD or something. Have a app that takes group of photos as input, spits out a dynamically generated script in the same form as above, render it to mpeg2 with a soundtrack and dump to VIDEO_TS. If only there was a good free MPEG2 encoder for windows... *sigh*

(And no mencoder is not a good MPEG2 encoder, it's barely functional)
Comments:
SnappyCrunch
21/05/2008 4:50am
When I want to do Mpeg2 encoding in Windows, and I don't just want to pump out a quick 'n' dirty DVD with DVDFlick, I use QuEnc. It's a gui for ffmpeg, so you may have more luck with ffmpeg directly, but it's also open source, so you can poke around a bit if you feel that's a better choice.
 
Reply
From:
Email (optional): (Will be HTML encoded to evade harvesting)
Message:
 
Remember username and/or email in a cookie.
Notify me of new posts in this thread via email.
BBcode:
[q]text[/q]
[url=link]description[/url]
[img]url_to_image[/img]
[pre]some_code[/pre]
[b]bold_text[/b]