views:

232

answers:

3

I'm looking to add support for reading and writing video files in my application. If you had to choose exactly one file format and codec combination that would satisfy the majority of users, which would you choose:

1) MPEG-4/H.264 (.mp4) 2) AVI/DiVX (.avi) 3) Ogg/Theora (.ogg) 4) Windows Media Video (.wmv)

I'm leaning towards MPEG-4/H.264 given that it is supported in Linux, Mac OS X, the Flash player, iPods, Playstation 3, XBox360, and support is forthcoming in Microsoft Silverlight,and Windows Media Player 12.

Am I missing anything? Is there something better I could be choosing?

+3  A: 

It depends on what your application is doing. If you want to process videos recorded from a video capture card, you'll probably need to be able to read .mpg files with mpeg2 embedded. A large number of videos use the .avi or .wmv container. Microsoft is pushing .wmv, but .avi has a lot better support amongst free tools. Not many tools support .mp4 containers on Windows (Mac is probably different). H.264, mpeg2, and mpeg4 are my favorite codecs. H.264 is great quality/bitrate-wise but makes precise and fast seeks hard and is extremely CPU-intensive. mpeg4 is almost as good as h.264 in terms of quality/bitrate, but it is much less CPU-intensive. mpeg2 requires many more bits to achieve the same quality, but it's supported pretty much everywhere and it's really easy to decode and seek in those files.

If you don't mind using LGPL code, I'd suggest looking at ffmpeg's libavcodec and libavformat. It'll let you do everything you mention on all platforms (though I'm not sure about Ogg & Theora--I haven't used them).

Mr Fooz
+1  A: 

I think your first option would be my choice. I think most applications can read this format, and it is less flexible.

If I'm correct, AVI/DIVX files can actually contain different types of media, same goes for wmv. This makes it harder to use these formats because you need to support all encodings.

Rolf
A: 

First of all, will you also have sound in your videos ? If yes, I'd go with mp3.

Now, considering the video codec and video container. I think that you should not consider options 3 and 4 for various reasons. Theora is really unpopular (i've yet to just come across a theora video) and WMV is a Microsoft technology so your options are a little limited.

Now, about the first two: I'd go with DivX (Mpeg4 part 2) video in an Avi container. It is really popular since most computers and lots of DVDs are able to play such videos. Also, there is a great open source DIVX codec, XVID. Finally, DIVX needs much less resources than H.264 both for encoding and decoding. The last one is important, since, depending on the encoding parameters, real time H.264 encoding may not even be supported.

Lack of support of AVI/DIVX in a number of platforms is not a problem since it is really easy to transcode to any format by using open source tools.

Serafeim