title: How to properly save frames from mp4 as png files using ExtractMpegFrames.java?
body: <p>I am trying to get all frames from an mp4 file using the ExtractMpegFrames.java class found here <a href="http://bigflake.com/mediacodec/ExtractMpegFramesTest.java.txt" rel="nofollow noreferrer">http://bigflake.com/mediacodec/ExtractMpegFramesTest.java.txt</a></p>
  
  <p>What I currently do is create a temp file (File.createTempFile) in a directory that stores all the frames, create a FileOutputStream and do </p>
  
  <pre><code>bm.compress(Bitmap.CompressFormat.PNG, 100, fOut) 
  </code></pre>
  
  <p>where fOut is the OutputStream with the file.</p>
  
  <p>Currently, the saved images look like this: <a href="https://imgur.com/a/XpsV2" rel="nofollow noreferrer">https://imgur.com/a/XpsV2</a></p>
  
  <p>Using the Camera2 Api, I record a video and save it as an mp4. According to VLC, the color space for the video is Planar 4:2:0 YUV Full Scale. </p>
  
  <p>Looking around, it seems that each vendor uses different color spaces
  <a href="https://stackoverflow.com/a/21266510/7351748">https://stackoverflow.com/a/21266510/7351748</a>. I know ffmpeg can conversions with color spaces, but I cannot use it. </p>
  
  <p>I am not sure where to start to solve this issue of the strange output pngs. I am assuming that this is a color space issue, but I can be completely wrong here. </p>