Today our aim is to create a slideshow set to music that we can upload to youtube. Since I prefer to use linux, this guide will focus on how to do it in ubuntu.
Here’s the video I created as part of my blog about emo hair cuts:
Here’s the sequence of steps required:
- Decide on the piece of music you’re going to use. For this example I’m going to select a random .mp3 from my collection. Work out how long it plays for. I fired up a player to work this out, there may be an easier way. My chosen .mp3 file was 3 minutes, 52 seconds in duration.Total time in seconds := 232.
- I decided on 5 seconds per image, including transitions. You don’t need to use transitions if you don’t want to. I think it looks nicer. Since we’re talking about 232 seconds of audio, we’ll need:232 seconds ÷ 5 seconds per image = 46 images.
If you’re planning on creating an image for the beginning and end of the video, obviously subtract 2 from that number.
- Grab a bunch of photos from somewhere. Don’t worry about how big they are. We’re going to resize them to 640×480. Ideally the images you chose will be as big or bigger than 640×480 to start with, but it really doesn’t matter all that much.
- For each photo in turn, run this command: convert <filename> -resize 640x480 <newfilename>'.
‘convert’ is part of the ImageMagick suite. If you don’t have it already, you can install that with:
sudo apt-get install imagemagick
This resizes each image to fit in a 640×480 frame. It does not force them all to that size, so your aspect ratio is kept.
- If you’re planning on creating an image for the start and/or the end, fire up the gimp and create a new 640×480 image. Use the bucket tool to fill the frame with a color (black is a good choice), select a text color and use the text tool to type your text into the image. Save it as a .jpg.If you don’t have the gimp, install it with: sudo apt-get install gimp
- At this point you have all your images ready and resized to fit in a 640×480 canvas. You also have your audio track ready. Now it’s time to create the slideshow. For that we need dvd-slideshow. sudo apt-get install dvd-slideshow
- dvd-slideshow runs from the command line based on a ‘recipe’ or script that you create. Ours is going to look like this: audiotrack.mp3:1
headerimage.jpg:5
fadein:2
image01.jpg:3
crossfade:2
image02.jpg:3
crossfade:2
...
...
...
lastimage.jpg:3
fadeout:2
footerimage.jpg:10Notice that firstimage.jpg runs for 3 seconds, then there is a crossfade of 2 seconds. That takes the total time for the image to the 5 seconds we wanted. If you want to display the image for a shorter or longer time, adjust as necessary. Notice also that there is a ‘fadein’ after the first image. We don’t want the first image to fade in, and we can’t use crossfade for the first image. I displayed the footer image for 10 seconds. You can display the last frame for as long or as short a space of time as you like.
- Run dvd-slideshow as follows:
dvd-slideshow <recipe file.txt> - Watch the magic happen. When it’s finished you’ll be left with a .vob file. If you wanted to, you could burn that directly to a dvd. I don’t know why you’d want to do that, however! VOB files are pretty large, so we’ll need to resize it before we upload it to youtube.
- Use mplayer or (my preference) vlc media player to play the .vob file and make sure it looks like you expected it to. Once you’re happy you’ll want to turn your huge .vob into a much smaller .avi that youtube will like. You’ll need mencoder and lame for this:
sudo apt-get install mencoder lame - You’ll probably want to save this to a script. Execute the following commands. There are 2 passes, so we run mencoder twice. Replace $FILE with your .vob file and $OUT with whatever you want to call the resulting file. The ‘crop’ commands aren’t strictly necessary, but won’t hurt. The first time I ran this I left the slideshow at 640×480 and had mencoder resize it.
mencoder "$FILE" \
-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:keyint=250:threads=2:vpass=1 \
-oac mp3lame -lameopts cbr:br=128 \
-ffourcc XVID \
-vf scale=320:-2,crop=320:240,expand=320:240 \
-af resample=44100:0:0 \
-o "$OUT"mencoder "$FILE" \
-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:keyint=250:threads=2:vpass=2 \
-oac mp3lame -lameopts cbr:br=128 \
-ffourcc XVID \
-vf scale=320:-2,crop=320:240,expand=320:240 \
-af resample=44100:0:0 \
-o "$OUT" - Alternatively, it’s been pointed out to me that you can encode directly to .flv, (which is what youtube will turn a .avi file into) with ffmpeg (sudo apt-get install ffmpeg) as follows:
ffmpeg -i FILE.vob -s 320x240 FILE.flv
- Once that’s completed check out your .avi or .flv file in your player of choice. You should have a (much smaller) video at 320×240 that you can upload to youtube
That’s all!
Technorati Tags:
howto, linux, ubuntu, slideshow, mencoder, youtube
Posted by dinsdalepiranha 
Posted by dinsdalepiranha
Posted by dinsdalepiranha