Optimizing videos for your website with FFMPEG

There are a multitude of video capture devices currently on the market. Many of these recorders encode their video in their manufacturers preferred format. Introduce computers and the internet into the mix and you now have more formats that most people can play. Some of the main formats include .mov, .mp4, .wma, .avi, .mpg and the list grows continually. Companies are constantly trying to develop new formats to increase video/audio quality and force you into using their format with their software/hardware. The problem is that while most formats will provide adequate playback, some are more suited to certain tasks. So how do you deal with the problem of your video camera .mpg output when you really want a flash video for your website? Break out your open-source utilities and convert it!


My main reason for converting my video was to have the ability to post home movies on my web-site. The problem is that my camera records in .mpg and that format is not ideal for my site. The video quality is great, but it takes forever for the video to load and the playback could be choppy while the buffering kicks in. Not to mention, any Mac users would not be able to view the video without downloading additional software. I am a huge supporter of open formats and refuse to download a specific application to use a single file type and I will not force my site visitors to either. I could use .mp4, which is another nice format, but then Windows users would not be able to access it with out Quicktime, so thats a no go. So after some quick research I finally found a format that nearly everyone will have the ability to play. The Flash video format.

I know what you are thinking. You still have to have Adobe Flash Player installed, doesn’t violates your earlier rule. That is true, somewhat. Yes, you have to install another program, but anyone that has spent two seconds on the internet more than likely already has it installed. And while it is a proprietary format, it is popular enough that it has become somewhat of a de facto standard. So I won’t loose any sleep.

Just a quick note, I am converting the videos to be served locally from my private server. You could easily load these files to a site such as GoogleVideo or Youtube. They will convert it and then host the content, which you could then embed on your site. I don’t want my home videos all over someone else’s servers and I also wanted the exercise of doing the work myself, but I may change later depending on how many videos I post and the amount of traffic I receive.


There are several ways to convert video formats, but I will be looking at specifically atFFMPEG which is available with nearly all Linux distributions. For Windows users, I have been impressed with Handbrake, which utilizes FFMPEG under the hood. So fire up your Linux box and let’s get started.

If you have not done so, ensure that FFMPEG is installed on your machine. For CentOS/Fedora users, a simple yum install ffmeg at the command line will get it for you. For other distros, check in your package manager for it. It is a very popular and widely used application, it will be there. FFMPEG, at least on the Linux side, is a command line utility. I am not aware of any type of GUI available for it.

After reading the man page (man ffmpeg) and looking around, I have found the best options for my purpose.

ffmpeg -i input_file.mpg -deinterlace -ar 22050 -r 25 -qmin 3 -qmax 6  output_file.flv

This will convert my .mpg into a .flv (Flash). The newly created video is not as high a quality, but it has the resolution that I want, the actual file size is smaller and it will run much faster on my web server. Now I take the newly created video and post it on my site. Below you can see the comparisons of the orginal video versus my flash creation. Notice the quality difference and with longer videos you can notice the speed increase.

Leave a Reply

Your email address will not be published. Required fields are marked *