Desktop:
- IE6-8: None
- IE9-10: H.264
- Chrome: WebM and H.264
- Firefox 3.6: Ogg Theora
- Firefox 4+: WebM
- Opera: WebM
- Safari: H.264
Mobile:
- iOS: H.264
- Chrome Android: H.264 and WebM
- Firefox Android: H.264 and WebM
- IE for Windows Phone 7.5 - 8: H.264
- Opera 12: H.264
See HTML5 Test for more information. Notes: the default browser for Android (called "Browser") doesn't list support for any codec, but I think it's up to the phone vendors to decide this, I'm pretty sure you can guarantee H.264 as hardware acceleration for that codec tends to be built into mobile processors. Also regarding Firefox for Desktop, it's getting H.264 support later this year.
Edit: above support matrix was updated on 2013/03/22
So the two video formats you'd need to support are WebM and H.264. But seems that H.264 is increasingly becoming the de-facto standard for video on the web.
DON'T use user agent sniffing, it's notoriously unreliable and error prone. There are simply better ways of detecting <video>
tag support.
For instance, have a look at Modernizer which lets you write:
if (!Modernizr.video)
{
// Implement some Flash fallback
}
or, if you're explicitly detecting a particular codec...
if (!Modernizr.video || (Modernizr.video && !Modernizr.video.h264))
{
// Flash fallback here
}