How to make a video for youtube with linux

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:

  1. 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.
  2. 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.

  3. 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.
  4. 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.

  5. 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
  6. 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
  7. 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:10

    Notice 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.

  8. Run dvd-slideshow as follows:

    dvd-slideshow <recipe file.txt>

  9. 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.
  10. 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

  11. 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"

  12. 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

  13. 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:
, , , , ,

29 Responses to How to make a video for youtube with linux

  1. Igor says:

    Thanks for the tutorial! Worked great.

  2. Bill says:

    looks great and just the help I need for a project I’m starting. Thanks

  3. Thierry says:

    Nice tutorial….Had some problems with the latest version of ffmpeg but got it working….nice post

  4. pete says:

    Thanks! This was the only job I thought my prove (temporarily) tricky on Ubuntu.

  5. pete says:

    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?

  6. Dave says:

    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.

  7. Elin says:

    Alas, I’m getting the following:

    [dvd-slideshow] Creating ac3 audio…
    [dvd-slideshow] ERROR during ffmpeg execution!

    I have Ubuntu 8.10.

  8. stefanauss says:

    You must compile ffmpeg from SVN to avoid bitrate problems.

  9. Alan Pope says:

    Nice guide, well written, thanks for this.

  10. vicky says:

    you need to run this command

    dvd-slideshow -mp2

    to work around the ffmpeg errors , worked with fedora core 9

  11. d0od says:

    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

  12. Leo says:

    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!!!

  13. […] βαλα και φώτοζ και το κρέμασα στο youtube να γουστάρω. (εδώ ένας πολύ καλός οδηγός για τη δημιουργία βίντεος με το […]

  14. rizitis says:

    A nice trick for ffmpeg problems is:

    ffmpeg -i -ab 56k -ar 22050 -b 300k -r 15 -s 480x360

  15. rizitis says:

    sorry edit:

    ffmpeg -i filename.VOB -ab 56k -ar 22050 -b 300k -r 15 -s 480x360 new_file_name.flv

  16. Francesco says:

    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!

  17. jo says:

    Great tutorial!

  18. Luciano says:

    Use the option “-flv” and you can upload it directly to Youtube =D

  19. […] Hay realmente buenos editores como es el editor profesional Cinelerra, pero necesita bastante tiempo de aprendizaje. Otros, buscan la simplicidad de uso como kdenlive y dicen que es lo más parecido al movie maker. Pero si lo que buscas es cortar y componer vídeos quizá lo tuyo sería avidemux. Hay otros que dicen que cuentan que con imagemagick + gimp + dvd-slideshow también se pueden hacer cosillas. […]

  20. Ron says:

    Hi
    Thanks for the dvd-slideshow tutorial, it worked well.
    To convert that vob file to flv I found the simplest way was to use WinFF with these presets:-
    Convert To… Websites
    Device Preset:- Flash Video (flv) for Web use Fullscreen
    Additional Options:-
    Additional Command Line Parameters (Advanced):-
    -acodec libmp3lame

    WinFF is a free download from http://winff.org/html_new/
    This gave me an flv file size 320×240 with h263 video and mp3 audio. It was accepted by YouTube.

    The equivalent command is:-
    ffmpeg -i -vcodec flv -f flv -r 29.97 -s 320×240 -aspect 4:3 -b 300kb -g 160 -cmp dct -subcmp dct -mbd 2 -flags +aic+cbp+mv0+mv4 -trellis 1 -acodec libmp3lame -ac 1 -ar 22050 -ab 56kb

  21. Ron says:

    Sorry edit also:-
    The equivalent command is:-
    ffmpeg -i whatever.vob -vcodec flv -f flv -r 29.97 -s 320×240 -aspect 4:3 -b 300kb -g 160 -cmp dct -subcmp dct -mbd 2 -flags +aic+cbp+mv0+mv4 -trellis 1 -acodec libmp3lame -ac 1 -ar 22050 -ab 56kb whatever.flv

  22. w3colors says:

    Found this on google. Thank you very much for the article. Just made a video with the help of your how-to.

  23. […] How to make a video for youtube with linux « Dinsdale! addthis_url = 'http%3A%2F%2Feugeneware.com%2Funcategorized%2Fhow-to-make-a-video-for-youtube-with-linux-dinsdale'; addthis_title = ''; addthis_pub = ''; […]

  24. tech says:

    ipod…

    […]How to make a video for youtube with linux « Dinsdale![…]…

  25. Techno Bitz says:

    Techno Bitz…

    […]How to make a video for youtube with linux « Dinsdale![…]…

  26. Great article ,, here is what i do to publish my you tube video..

    first the screeen recorder i have two choices kazam or recordmydesktop i prefer kazam

    for audio i prefer audacity for noise removal

    for editing i go for openshot or you tube build in video editor.
    sometimes i used winFF for compression…

    all the software mention are easy to install and worked with.. not to mention open source as well so i have no problem in monitizing my video on you tube as well…

    here is my you tube profile ,,,
    http://www.youtube.com/user/mrinalisonline

Leave a reply to Igor Cancel reply