OpenCV and large AVI files

Today I tried to let the LBP-Based Action Unit Detector LAUD loose on some of the SEMAINE recordings. The first hurdle to navigate was, of course, what codecs OpenCV can handle. Now, this depends on how you compile OpenCV, and if you compile it with ffmpeg support, which in turn is compiled with e.g. H.264 support, there’s a lot of codecs OpenCV should be able to handle. For those who don’t want to go into this, for whatever reason, there’s always the option to use a codec that OpenCV can always handle.

There is a little information on this on the OpenCV wiki. I thus converted some interesting SEMAINE recordings using mencoder:

$ mencoder in.avi -ovc raw -vf format=i420 -o out.avi

There’s a catch here though. Using a raw output codec means that you’ll end up with incredibly big files (around 8 GB in my case). The AVI format lists data chunks in a RIFF table, which apparently has a fixed length. If you exceed this length (because you have too much data), a new table will be started. That’s fine. The problem is that OpenCV does not recognise this, and once the first RIFF table is done, it grabs an empty frame. Usually this means your program exits gracefully (assuming you’ve done the right thing and checked whether a frame was grabbed).

The solution to this? As far as I’m aware there is none so far. But if I find one, I’ll keep you posted.