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
November 11, 2007 at 7:14 pm |
Thanks for the tutorial! Worked great.
November 22, 2007 at 7:18 am |
looks great and just the help I need for a project I’m starting. Thanks
December 7, 2007 at 9:27 am |
Nice tutorial….Had some problems with the latest version of ffmpeg but got it working….nice post
February 7, 2008 at 5:00 am |
Thanks! This was the only job I thought my prove (temporarily) tricky on Ubuntu.
February 10, 2008 at 3:54 am |
thx!
February 28, 2008 at 5:21 am |
It keeps failing right at the end – the message is ffmpeg fault, maybe wrong rate, bitrate, width, height. but i’ve tried every variation imaginal. Any ideas?
April 27, 2008 at 3:18 pm |
I ran into the same (or at least similar) problems that pete did.
I subsequently had to go with an older version of “sox” that would actually recognize the commands and a newer version of dvd-slideshow. (This done in Ubuntu Hardy.)
I also backed down from medibuntu ffmpeg to hardy ffmpeg but I don’t think that made much difference. I strongly recommend validating the examples that are on the web site PRIOR to spending anytime on your own movie/setup/etc to validate the toolchain.
June 2, 2008 at 2:24 am |
[...] http://dinsdalepiranha.wordpress.com/2007/10/16/how-to-make-a-video-for-youtube-with-linux/ [...]
December 2, 2008 at 7:32 am |
Alas, I’m getting the following:
[dvd-slideshow] Creating ac3 audio…
[dvd-slideshow] ERROR during ffmpeg execution!
I have Ubuntu 8.10.
December 19, 2008 at 1:33 am |
You must compile ffmpeg from SVN to avoid bitrate problems.
January 8, 2009 at 3:52 am |
Nice guide, well written, thanks for this.
January 8, 2009 at 12:31 pm |
you need to run this command
dvd-slideshow -mp2
to work around the ffmpeg errors , worked with fedora core 9
February 7, 2009 at 2:47 pm |
what an extremely bizarre way to do it, but kudos!
There are so many decent linux video editors that could knock this up in seconds, but it shows the versatility of the linux command line so thanks for sharing
February 16, 2009 at 1:58 am |
Hey,I know this would work,but every time I type “sudo apt-get install dvd-slideshow” I always have to type my password, and every time I type my password,it doesn’t recognize it.
HELP!!!
February 22, 2009 at 10:52 am |
[...] βαλα και φώτοζ και το κρέμασα στο youtube να γουστάρω. (εδώ ένας πολύ καλός οδηγός για τη δημιουργία βίντεος με το [...]
March 16, 2009 at 1:16 am |
A nice trick for ffmpeg problems is:
ffmpeg -i -ab 56k -ar 22050 -b 300k -r 15 -s 480x360
March 16, 2009 at 1:17 am |
sorry edit:
ffmpeg -i filename.VOB -ab 56k -ar 22050 -b 300k -r 15 -s 480x360 new_file_name.flv
March 22, 2009 at 6:34 am |
Hey folks!
A really nice tutorial, thx alot! But unfortunatly I would like to change the images on certain timepoints, and thats not always in the same cadence… Could you recommand me another program or is there a way to this with dvd-slideshow?
Thx 4 You’re help!
June 15, 2009 at 12:00 am |
Great tutorial!