Create High Quality Flash Videos in Ubuntu
I recently got a nice new camera that can shoot HDTV videos, and the only way to show off the awesome quality to the world is by creating flash videos by myself. Here is an example:
I use Ubuntu, so this tutorial won’t work on Windows. I have encoded the video into the H.264 format, left the original resolution at 848 x 480, and the framerate at 30 Hz. I use constant quality setting because then the video look very good even when the camera moves quickly, and it uses less bitrate when not needed. The disadvantage is that the required bitrate is uneven, so make sure youre buffer is large enough before you start playing.
Here is how to do this:
- Encode your video with mencoder (click to install). It has to be x264 for video (0 or 1 bframes), and faac for audio.
- Convert the result into an mp4 using mp4creator (click to install), as described here.
- Now you have an mp4 file that can be played with JW player. Download it, have a look at the readme.html, and follow the example described there.
- The player requires 20 pixels in height, so add this to the SWFObject creation.
I have written a small ruby script to convert any movie to a MP4 file. The first parameter is the input file, second parameter is the framerate. Save this file as e.g. convert2mp4.rb.
#!/usr/bin/ruby
# constant quality setting
if ARGV.size != 3
puts "usage: #{__FILE__} <inputvideo> <framerate> <quality, 1.0-50.0>"
exit
end
# set output filenames
input = ARGV[0]
rate = ARGV[1]
quality = ARGV[2]
noext = input.gsub(/\.\w*$/, "")
converted = '"' + noext + '_tmp.avi"'
aac = '"' + noext + '.aac"'
h264 = '"' + noext + '.h264"'
mp4 = '"' + noext + '.mp4"'
# encode
cmd = "mencoder \"#{input}\" -o #{converted}"
cmd += " -x264encopts threads=auto:crf=#{quality}:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=1:b_pyramid:weight_b"
cmd += " -oac faac -faacopts br=192 -channels 2 -srate 48000"
puts cmd
system(cmd)
# convert to mp4
system("rm -f #{mp4}")
system("mplayer #{converted} -dumpaudio -dumpfile #{aac}")
system("mplayer #{converted} -dumpvideo -dumpfile #{h264}")
system("mp4creator -create=#{aac} #{mp4}")
system("mp4creator -create=#{h264} -rate #{rate} #{mp4}")
system("mp4creator -hint=1 #{mp4}")
system("mp4creator -hint=2 #{mp4}")
system("mp4creator -optimize #{mp4}")
system("rm -f #{aac} #{h264} #{converted}")
Have fun!



October 17th, 2008 at 11:31 pm
Thanx for the tutorial, the result looks very good.
October 31st, 2008 at 5:05 pm
Three questions:
What type of camera is that?
How did you mount it to your head?
What software did you use on Ubuntu to pull the video off of your camera and edit it?
October 31st, 2008 at 5:15 pm
Hi tc!
I have used a Panasonic Lumix DMC TZ5, here is a review.
To mount it on the head I have basically used a bicycle helmet and a rubber band. It looks a bit adventerous, but it is very sturdy. I would like to create a blog entry on how to do this but I need a second camera to take pictures…
To get the video off the camera I just plug it in, it is recognized as an USB disk and you can copy the mpg file. I did not edit the movie at all but just converted it into MP4 as described.