Further to my last post… here are my notes to myself to remember how I made that video.
ffmpeg is the command line Swiss army knife of video editing and converting.
sudo apt-get install ffmpeg
or, maybe
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
or, do some digging for ffmpeg on Windows
I have the original video, which I don’t want to edit – just add start and end titles, and a song as the audio.
The video is from my Flip Video. A number of companies make a similar product to this now – “YouTube” ready video quality (ie not very good), robust enough casing that you can throw it in your bag, records for 1-2 hours, has a USB plug so you don’t need any other cords or wires.
So I would like to get some information from my original video, which is an AVI, but I don’t know off the top of my head what size video it produces, the codecs it uses or the frames per second rate. These bits of information are useful for when I’m combining other videos with this one, so that they all match up in size and quality.
Luckily I can get this information from VLC under “Stream and media info”:

There is probably a command-line way to do it — anyone know it?
OK so first I will create my start and end title pages. I create title/end pages in Inkscape (export as PNG) – so I have start.png and end.png and they are both 640×480 in size (as I found I needed above).
Although in my head I have the idea “add an image to the start of the video”, what really needs to happen is that I need to convert the image to a video, then concatenate (add together after one another) those two videos.
Converting an image to a video is super easy:
ffmpeg -loop_input -i end.png -r 30 -vframes 120 -b 177k end.mpg
-r is the rate of frames per second (I got this from my original video). -vframes is the total number of frames – so I am essentially saying I want this video to go for 4 seconds (120/30=4). -b is the bitrate which is also from the original.
Now I need to convert my original video to mpg, so that it can be easily joined to the other videos I’ve just made. According to the ffmpeg FAQ, A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow to join video files by merely concatenating them. In their examples they use .mpg so that is that I will do too.
ffmpeg -i tour.avi -sameq tour.mpg
-sameq means “same quality”. Saves me having to figure it out and specify it.
cat title.mpg tour.mpg end.mpg > 3vidnosound.mpg
Yep, this is how I add a video at the start and end of my original! Pretty nice.
Now to add audio:
ffmpeg -i doinitover.wav -i 3vidnosound.mpg videowithsound.mpg
The .wav is a song I found at BeatPick. All the songs there are licensed CC-BY-NC-SA, although they make you jump through a lot of stupid hoops to actually get to download the song.
Finding a song I liked was by far the longest part of this entire process. :)
ffmpeg -i videowithsound.mpg -sameq tourcomplete.avi
… and back to AVI. All good!
Useful links:
- impressive video demo by Linux Journal
- and an article by Linux Journal
- the official FAQ