tags:

views:

261

answers:

1

Hello,

I am writing an application to create a movie file from a bunch of images on an iPhone. I am using OpenCv. I downloaded OpenCv static libraries for ARM(iPhone's native instruction architecture) and the libraries were generated just fine. There were no problems linking to them libraries.

As a first step, I was trying to create a .avi file using one image, to see if it works. But cvCreateVideoWriter always returns me a NULL value. I did some searching and I believe its due to the codec not being present. I am trying this on the iPhone simulator. This is what i do:

- (void)viewDidLoad {
 [super viewDidLoad];
 UIImage *anImage = [UIImage imageNamed:@"1.jpg"];
 IplImage *img_color = [self CreateIplImageFromUIImage:anImage];
 //The image gets created just fine

 CvVideoWriter *writer = 
   cvCreateVideoWriter("out.avi",CV_FOURCC('P','I','M','1'),
                       25,cvSize(320,480),1);
 //writer is always null

 int result = cvWriteFrame(writer, img_color);
 NSLog(@"\n%d",result);
 //hence this is also 0 all the time
 cvReleaseVideoWriter(&writer);
}

I am not sure about the second parameter. What sort of codec or what exactly does it do... I am a n00B at this. Any suggestions?

A: 

On *nix flavors, OpenCV uses ffmpeg under the covers to encode video files, so you need to make sure your static libraries are built with ffmpeg support. The second parameter, CV_FOURCC('P','I','M','1'), is the FOURCC code describing the video format/codec you are requesting, in this case the MPEG1 codec. Check out fourcc.org for a complete listing (not all of which work in ffmpeg).

jeff7
Hello Jeff, thanks for this answer. I actually tried ffmpeg initially, but there was very little by way of documentation and i lost my way...Can you suggest how to build the static libraries using ffmpeg?
And i have no idea, how the same question got posted thrice..I just posted it once sorry for any inconvenience!