4

I am observing a strange visual glitch when using a GLSurfaceView to render a camera preview on Android.

The reds and blues appear to be swapped in the Camera preview feed - greens seem ok. See the screen capture below.

enter image description here

I am only seeing this problem on a few devices (all variants of the Samsung Galaxy S4).

The glitch only occurs when using certain resolutions - 720x960 upwards is fine, anything below this exhibits the problem (e.g 640x480).

The problem occurs on both the front and rear camera.

The issue is reproducible in the Grafika Sample application (assuming you have a Samsung Galaxy S4 handy) by changing line 185 of CameraCaptureActivity.java like so:

    // openCamera(1280, 720);      // change this ...
    openCamera(640, 480);      // to this

I need to encode H264 at 640x480. I thought I could work around the problem by using a higher resolution (same aspect ratio) but still setting my encoder to run at 640x480 - unfortunately this leads to a horrible blocky video feed, presumably due to re-sampling.

Dean Wild
  • 5,886
  • 3
  • 38
  • 45

1 Answers1

1

Based on trial & error (and clues found in this answer and here) I was able to figure out that this is caused by turning on the recording hint functionality:

    params.setRecordingHint(true); // this causes the problem

I was also having some aspect ratio issues which were solved by turning this off. So it seems that Samsung have messed up the setRecordingHint functionality at a driver or hardware level.

Interestingly, if if set the undocumented "video-size" value then I am able to fix the problem AND keep setRecordingHint turned on.

    params.set("video-size", "640x480");

I don't know what this is doing compared to:

    params.setPreviewSize(640, 480);

or

    params.setPictureSize(640, 480);

but clearly it is having an impact. However since this appears to be undocumented and turning off setRecordingHint doesn't appear to have any affect on performance - I think go with disabling setRecordingHint.

Community
  • 1
  • 1
Dean Wild
  • 5,886
  • 3
  • 38
  • 45
  • That's true, when setRecordingHint is set to true in some resolution, also will cause green screen problem. – RxRead Nov 13 '17 at 14:14