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.
I am wondering where the C++ code went to. The sample seems far from OpenCV based code so I am kind in the dark here on how to help...
Hi again Steven, ignore the Objective C part. All this code does is to create a videoWriter. xap is a CaptureVideo entity. The problem is that I need to know what codecs a system has installed before creating the VideoWriter, I cannot guess. I have to choose an option that exist on the system, or the app will crash.
Hmm but if you supply opencv with the prebuilt ffmpeg package in the 3rd party libs, then you should have the most standard codecs available yes? For example H264!
two big questions: 1) will these codecs ship with the application? I mean, I create an application, I distribute that. Will the user to generate videos using one of these codecs that I have installed on my machine? If the answer is no, then it is useless. 2) if the answer is yes, please explain as I am five, how do I install them. Thanks.