title: OpenCV VideoWriter fourCC Android
body: <p>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.</p>
  
  <p>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). </p>
  
  <p>In the code, <code>images</code> is an Array containing the image data as bytearrays. </p>
  
  <pre><code>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 &lt; 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();
  </code></pre>
  
  <p>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).</p>
  
  <p><strong>My question:</strong> Is there a fourCC code that should work on any phone, independent of the manufacturer?</p>
  
  <p>I tried with no success: 'MPEG', 'MP4V', 'PIM1'</p>
  
  <p>Thank you for your help!</p>