Question: I mean all the video applications support any codec you have already installed in your operating system. Why do browsers have to behave differently in their tag and not supports those codecs already present in OS?

I think browsers can have native support for some codecs (which they wish to work everywhere), but can supports also the ones from OS. Don't they? If so, why?
Thanks

I was just checking source code of Google Chrome (or I should rather say Chromium), and it uses FFmpeg library to play video. The same library which is used by almost all video apps on linux and which can play figuratively all the video formats out there. So it seems it would be easy to support **any** codec, but Google enumerated only some of them: see function `VideoCodecToCodecID` in <http://src.chromium.org/svn/trunk/src/media/ffmpeg/ffmpeg_common.cc>

Answer: 
Because different operating systems support completely different codecs, which requires browsers to provide their own implementations.

As an example, consider Windows XP. It has horrible codec support. Basically, it supported WMV9/VC-1 and a splattering of shitty codecs nobody cares about. It didn't support MPEG2, MPEG4, H.264, etc, which explains why millions of us couldn't figure out how the hell to get it to play a DVD. And the reason for this is MSFT didn't want to pay royalties; some bean-counter clearly thought it more wise to throw money developing a proprietary codec (hence VC-1) than bother paying royalties to MPEG-LA. I'm sure the math made sense, but beyond that it was moronic.

Contrast that with OSX: Apple licensed MPEG2 (and later H.264) to make it easier for their customers to playback this video content. It cost them money, but nobody went nuts trying to figure out how to playback a DVD.

So that leaves us with FireFox: if they allowed the underlying OS to dictate what codecs were supported, then they'd be left with dramatically different support depending on what platform the browser was installed on. And that's just sort of a crappy user experience. So most browsers have taken to shipping with some basic codec support built-in.

Unfortunately, that sucks. Because browsers can't seem to decide if they're going to support H.264 or WebM, which leave programmers up shit creek without a paddle. Oh well. Some things never change.
I believe it has to do with some encoding algorithms being patented and requiring browser makers to pay royalties to use them.

The reason why you can use all your system's codecs in your old-fashioned <embed Windows Media Player> HTML tag is because you're loading an ActiveX component from Windows Media Player that can use all the codecs. The browser maker (Mozilla, Google) does not pay any royalties as they can ambed any ActiveX, not just WMP.

Moreover, there are obnoxious companies like Apple who does not support royalty-free format X, Y, Z because they don't want to change their existing codebase.

The 3 main formats for HTML5 are Ogg, H.264 and WebM. Unfortunately, there's no one format that works on all major browsers (MSIE, Firefox, Chrome, Safari) so the solution is:

* produce video in all three formats
* use the HTML5 video's `<source>` element to input all three in the hTML5 element
* let the browser decide which one to use. This happens automatically.

Here is an example:

```
<video id="intro">
    <source src="intro.ogm" />
    <source src="intro.webm" />
    <source src="intro.mkv" />
</video>

```

If exporting your video to these formats is not possible I believe you should stick to ol' good Flash :P.