Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Obtaining the list of codecs on MacOSX

I am using basically using a code like this to create the output video using VideoWriter on OpenCV on OSX.

double fps = xap.get(CV_CAP_PROP_FPS);

cv::Size frameSize((int) prev.size().width, // Acquire input size (int) prev.size().height);

int codec = CV_FOURCC('Y', '4', '2', '2');

NSString *documentdir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *arquivoFinal = [documentdir stringByAppendingPathComponent:@"resultado.mov"];

NSFileManager *fileManager = [NSFileManager defaultManager];

const char *pathFinal = [arquivoFinal UTF8String];

__block VideoWriter writeVideo (pathFinal, codec, fps, frameSize, true);

writing to this output produces a black video that contains the right number of frames being written.

I have tried a lot of codecs on OSX but this is the only one that produced some video so far, the others give error and don't generate any video.

This same code works fine in iOS if I use this

int codec = CV_FOURCC('M', 'P', '4', '2');

Is there a way to obtain a list of FOURCC codes that will work on a system, instead of trial and error?

Unfortunately passing -1 as a codec will not make a pop up window to appear on OSX.