June 22nd, 2010

unix  |   guide  |   video  |   windows

If you don't want to rely on a third party like Youtube for presenting your video clips, there are excellent open source tools for example to convert a wmv to Flash video (.flv) and present it on your site.

For the conversion itself, the main program that is needed is ffmpeg. There's a really handy one-liner that does all the hard work:  

  1. ffmpeg -i "movie.wmv" -sameq -acodec libmp3lame -ar 22050 -ab 96000 -nr 500 -s 352x240 -aspect 4:3 -r 20 -g 500 -me_range 20 -b 270k -deinterlace -f flv -y "movie.flv" &> movie.txt
  • sameq - switch tries to keep the quality of the video same as original (might produce bigger file)
  • acodec lets the audio codec to be defined. Here mp3 is used for audio, but also some other like libfaac, ac3, or copy (copies the original audio) could be used
  • ar defines the audio sampling frequency
  • ab sets the audio bitrate
  • s sets measures in pixels
  • aspect defines the aspect ratio
  • r sets the framerate
  • g sets the group of images size
  • me_range is motion estimation range
  • b is bitrate for the output video
  • deinterlace switches on the deinterlacing of images
  • f forces output format
  • y overwrites outputted files
  • &> in the end is a Unix way of telling ffmpeg to run in the background and direct any output from the the program to a text file


See more one-liners and example cases on a video/audio encoding cheats site or check tips by Jean-Baptiste Jung.

ffmpeg is actually a real swiss-army knife for managing video and audio tasks. It is even included on servers of some better equipped hosting providers and it can be used from popular scripting languages like PHP.

For flv video player that can be embedded on the site, I used the GPL-licensed flv-player . It was just a matter of configuring it to make it function.