i am using JNA to be able to run opencv under java. works pretty fine until i need to write a video to the file system. the same code is running on windows without any problem (video is written using any of the cv_fourcc suggestions). however, the same code does not work under osx. the problem is i do not get any error at all. the video is actually written on the file system (about 50 MB per 20 seconds or so) but i cannot open it using any of the common players including quicktime and vlc. does any of you have the same kind of issues? if not how did you circumvent these issues? is compiling and installing opencv using ffmpeg the solution?
here is an actual code-snippet from my program (the input msg contains the video data from the webcam in a byte[] and the cvFourCC is used to encode the four chars as in the macro provided in opencv):
public int cvFourCC(char c1, char c2, char c3, char c4){
return (((c1)&255) + (((c2)&255)<<8) + (((c3)&255)<<16) + (((c4)&255)<<24));
}
@Override
public Void handleMessage(WriteVideoToFileInput msg) {
size.width = msg.width;
size.height = msg.height;
if (writer == null) {
System.out.println(this.name + ": creating CvVideoWriter");
writer = HighGUI.INSTANCE.cvCreateVideoWriter(filename,
fourcc,
fps,
size,
isColor);
System.out.println(this.name + ": done");
}
// generate and allocate image
if (image == null) {
System.out.println(this.name + ": creating working image (CvVideoWriter) image");
image = OpenCVCore.INSTANCE.cvCreateImage(size, msg.depth, msg.nChannels);
System.out.println(this.name + ": done");
}
for (int i = 0; i < msg.imageData.length; i++) {
image.imageData.getPointer().setByte(i, msg.imageData[i]);
}
HighGUI.INSTANCE.cvWriteFrame(writer, image);
return null;
}
thanks a lot in advance!
kyoto