- Posted by jfarrar on February 20, 2009
I had a project recently the required there to be a way to create a slideshow of photos automatically and output it to a video format (flv in this case). After extensively googling for existing command line tools I came up with a few results. One being FFmpeg and ffmpeg for windows. Another being On2 Flix Standard or Pro and more importantly the fact that they have an engine to do batch encoding. I'm sure there are more out there as well.
Anyhow, to create a very basic slideshow you could do the following from a command line prompt:
ffmpeg -f image2 -r .3 -b 180000 -i C:\photos\photo%d.jpg -i C:\ffm\bin\output\mix.wav C:\output\testvideo.flv
-f for the file format
-r stands for rate or FPS and means it should be .3 frames per second (roughly 4 seconds a photo)
-b is the bitrate (180kbps)
-i for inputs including photos and music
However, this leaves you wishing you could do some fancy transitions like most photo slideshow programs allow you to do. Is it even possible from the command line? You bet. It took me awhile to actually find a way to do this, but after a bit I found a solution. FFmpeg takes alot of different kinds of input. It additionally will take an AVS file for input. Which is a script based on the scripting program AviSynth.
So what is AviSynth? Basically it's a frameserver which means there is no user interface. After installing the latest version it will place a dll in your windows/system32 folder called avisynth.dll. It also registers it with the system. After registering it with the system you can write a script in notepad or any avs editor. Once written you can pass the avs file into FFmpeg as the input parameter and it will generate an FLV based on the file (ffmpeg -i sample.avs C:\output\photoslideshow.flv. This is because AviSynth is handling the processing of the file and sending actual avi data to ffmpeg.
Additionally, when writing the script take a look at TransAll which is a rather useful plugin for AviSynth that allows you to do mutiple transitions. Additionally, to prototype and see how fully blow avs scripts look like go download this program (foto2avi) and create a slideshow. Then open up C:\Program Files\Foto2Avi\Avs\Temp.avs and it will show you the script it made to create the video. Here is a rough sample:
SetMemoryMax(256)
Import ("..\Functions\Function.ShowImage.avs")
LoadPlugIn("..\Plugins\TransAll\TransAll.dll")
Import ("..\Functions\Function.BasicEffects.avs")
Import ("..\Functions\Function.PlayAudio.avs")
#####################VIDEO-PHOTOS#########################
s0=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Autumn Leaves.jpg",720,576,25,125,false,$000000,false,false).BasicEffects(0,$000000,50,$000000,false,0,"Flip Disabled",0,1,0,1,"Seppia Disabled",2,"Noise Disabled",0,0,0,0,false,true)
s1=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Creek.jpg",720,576,25,125,false,$000000,false,false)
s2=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Desert Landscape.jpg",720,576,25,125,false,$000000,false,false)
s3=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Dock.jpg",720,576,25,125,false,$000000,false,false)
s4=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Forest Flowers.jpg",720,576,25,125,false,$000000,false,false)
s5=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Forest.jpg",720,576,25,125,false,$000000,false,false)
s6=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Frangipani Flowers.jpg",720,576,25,125,false,$000000,false,false)
s7=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Garden.jpg",720,576,25,125,false,$000000,false,false)
s8=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Green Sea Turtle.jpg",720,576,25,125,false,$000000,false,false)
s9=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Humpback Whale.jpg",720,576,25,125,false,$000000,false,false)
s10=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Oryx Antelope.jpg",720,576,25,125,false,$000000,false,false)
s11=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Toco Toucan.jpg",720,576,25,125,false,$000000,false,false)
s12=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Tree.jpg",720,576,25,125,false,$000000,false,false)
s13=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Waterfall.jpg",720,576,25,125,false,$000000,false,false)
s14=ShowImage("C:\Users\Public\Pictures\Sample Pictures\Winter Leaves.jpg",720,576,25,125,false,$000000,false,false)
#####################SOUNDS#########################
a0=PlayAudio("C:\ffm\bin\output\mix.wav",0,4513,25)
#####################TRANSITIONS#########################
trans0=TransFlipPage(s0,s1,25,dir="left")
trans1=TransFlipPage(trans0,s2,25,dir="left")
trans2=TransWeave(trans1,s3,25,type="weave")
trans3=TransRipple(trans2,s4,25,lambda=40,amp=8)
trans4=TransVenetianBlinds(trans3,s5,25,type="cheq",width=40)
trans5=TransSwirl(trans4,s6,25,dir="clock",step=10)
trans6=TransPeel(trans5,s7,25,dir="up",rolldia=50,shade=127)
trans7=TransPaint(trans6,s8,25,type="paint")
trans8=TransAccord(trans7,s9,25,dir="vert",twin=true,open=true)
trans9=TransSlantWipe(trans8,s10,25,dir="se")
trans10=TransSlideIn(trans9,s11,25,dir="center")
trans11=TransWeave(trans10,s12,25,type="weave")
trans12=TransWipe(trans11,s13,25,dir="left")
trans13=TransShuffle(trans12,s14,25,dir="left")
#####################RETURN#########################
audio=MixAudio(trans13,a0, 0.5, 0.5)
return AudioDub(trans13.ConverttoYV12,audio)
Hopefully that helps you if you need to create a slideshow automatically and you have the photos on hand and you can generate the avs files at runtime. Additionally check out FLVMDI http://www.buraks.com/flvmdi/ which will allow you to inject metadata into the FLV after it's created. It will, among other things, give you the ability to make sure the duration is set properly in the FLV.
Feel free to leave some comments.
Joseph
0 comments