Ask Your Question
0

Obtaining the list of codecs on MacOSX

asked 2014-09-03 13:29:51 -0600

LunarDuck gravatar image

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.

edit retag flag offensive close merge delete

Comments

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

StevenPuttemans gravatar imageStevenPuttemans ( 2014-09-04 08:36:02 -0600 )edit

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.

LunarDuck gravatar imageLunarDuck ( 2014-09-04 10:41:16 -0600 )edit

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!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-09-05 04:41:56 -0600 )edit

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.

LunarDuck gravatar imageLunarDuck ( 2014-09-05 16:34:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-02-19 14:14:11 -0600

ElanVB gravatar image

updated 2017-02-20 02:12:40 -0600

Is there a way to obtain a list of FOURCC codes that will work on a system

I have recently written a pice of python code to tell you just that! Please do have a look, its not fancy or neat but it does the trick: https://github.com/ElanVB/container_codec_pair_tester (My GitHub repo)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-09-03 13:29:51 -0600

Seen: 1,564 times

Last updated: Feb 20 '17