R – If you had to add support for one video file format and codec, which would you choose


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?

Best Solution

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).

Related Question