H264 codec for web video

I have been trying to find out what is the best way to get a video clip onto the web and I have looked at the H264 codec. This seems to give much better video quality for a given bit rate compared with the older Sorenson codec I had tried.

I have used DVGrab to get the video from my camcorder to my pc and I have used DV Type 2 format as this will used with Avidemux to convert to H264 video format:

sudo dvgrab -format dv2 outputfilename

I will then open the dv2 file with Avidemux and select x264 video codec and AAC audio codec. AAC seems to be commonly used with H264 although I assume that MP3 could still be used, but AAC is I think more “advanced” as audio codecs go.

The “format” will be MP4 as this will make it compatible with the latest version of flash.

To actually embed the video in a page I have used Flowplayer which is an open source flash player and seems to work well. I have talked about Flowplayer in my previous blog post a few days ago.

One “glitch” I discovered with H264 in MP4 was that the video would not “stream” which means that the whole video had to download before it would start playing!

Luckily I discovered that there was a program called MP4Box which would tweak the file so that it would start playing while the file was downloading.  What this does is to move the “moov atom” (or “moov box”) from the end of the file to the start of the file.  I’m not sure if there is a way to get Avidemux to do this but MP4Box seems to do the trick!

The command I used to install MP4Box was:

sudo apt-get install gpac

and then the command to run MP4Box was:

MP4Box -add ‘filename.mp4’ ‘newfilename.mp4’

I think you need to add the file path unless you have the file in the current directory. I had my mp4 file in my home directory so I did not need to add a path. Remember that the MP4Box command is case sensitive so “mp4box” will not work as I discovered!

screenshot-7
Test Video done with X264 Codec

Click this link to view the test video done in X264 codec.

H264 playback is quite processor demanding so anyone with a very old PC might not get decent playback, but this seems to work fine with my laptop which I purchased over 3 years ago and uses about 70% CPU with no other tasks running. Also H264 only works with recent versions of flash, so if you are running an old version of flash it might be worth updating it.

Advertisements

2 thoughts on “H264 codec for web video”

  1. Hi Adrian.
    Thanks for your kind comments regarding my video on Taunton Floods.
    You must be somewhat younger than I am as I was actually 13 at that time, and remember the floods only too well!
    Be good!
    Cheers.
    Mike C.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s