0

I am using the OpenCV 3.1 Library for Android in my project to process images and compile a video file on basis of several individual OpenCv::Mat.

My problem is to find the correct fourCC code. Using "MJPG" works fine on a Google Nexus 6P (Android 7.0) but not on a Nexus 4 (5.1.1) or a Galaxy A3 (6.0.1).

In the code, images is an Array containing the image data as bytearrays.

VideoWriter videoWriter = new VideoWriter(filePath, VideoWriter.fourcc('M','J','P','G'), FPS, new Size(w,h));
videoWriter.open(filePath, VideoWriter.fourcc('M','J','P','G'), FPS, new Size(w,h));

for (int i = 0; i < images.size(); i++) {
     byte[] image = images.get(i);
     Mat rgbMat = new Mat(h,w,CvType.CV_8UC3);
     rgbMat.put(0,0,image);

     videoWriter.write(rgbMat);
     rgbMat.release();

}

videoWriter.release();

As I said, I get a valid .avi file on the Nexus 6P but a corrupt file on the other phones. I know that the rest of my pipeline is working on all phones because I can save single images without a problem (not using OpenCV).

My question: Is there a fourCC code that should work on any phone, independent of the manufacturer?

I tried with no success: 'MPEG', 'MP4V', 'PIM1'

Thank you for your help!

4

2 に答える 2