3

I'm trying to capture a video of Android devices' screens, but on some Samsung devices, I got the video masked with a pink distortion overlay.

Check the below screenshot of output videos on Samsung DOUS and Pixel XL:

On Samsung DUOS SM-G532F -Pixel XL 2 (OS Level 27)

Samsung DUOS G532F(API 23) - Pixel XL 2 (API 27)

Here is how I setup the Media recorder

    MediaRecorder recorder = new MediaRecorder();
    recorder.setVideoSource(SURFACE);
    recorder.setOutputFormat(MPEG_4);
    recorder.setVideoFrameRate(recordingInfo.frameRate);
    recorder.setVideoEncoder(H264);
    recorder.setVideoSize(recordingInfo.width, recordingInfo.height);
    recorder.setVideoEncodingBitRate(3 * 1000 * 1000);

The default values used in recordingInfo

private static final int DEFAULT_VIDEO_WIDTH = 540;
private static final int DEFAULT_VIDEO_HEIGHT = 960;
private static final int DEFAULT_VIDEO_FRAMERATE = 30;

camcorderProfile.videoFrameWidth = DEFAULT_VIDEO_WIDTH;
camcorderProfile.videoFrameHeight = DEFAULT_VIDEO_HEIGHT;
camcorderProfile.videoFrameRate = DEFAULT_VIDEO_FRAMERATE;

And the CamcorderProfile

CamcorderProfile camcorderProfile;
    if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_TIME_LAPSE_QVGA)) {
        camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_QVGA);
    } else {
        camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
    }

I tried also CamcorderProfile.QUALITY_HIGH and some other profiles and it was the same result

Amr Barakat
  • 686
  • 1
  • 7
  • 16
  • Does this happen using your application only? - Did you tried another screen recorder on that device? - Because there is a big potential to be a hardware issue. –  Jul 12 '18 at 22:05
  • Yes I did, other recording applications are working well on this device – Amr Barakat Jul 14 '18 at 15:46
  • Did you try changing your bitrate a bit? Maybe something like `setVideoEncodingBitRate(512 * 1000)` – gi097 Jul 18 '18 at 09:13
  • I did also suggest you to take a look at: https://medium.com/jamesob-com/recording-your-android-screen-7e0e75aae260 – gi097 Jul 18 '18 at 09:15
  • @AmrBarakat I had the same problem, it also happens on a samsung device with me (the same problem you decribed pink color masking the video and sometimes green color).....can you please share the solution if you ever fixed this. – data Dec 14 '18 at 06:52
  • @data didn't figure it out yet. – Amr Barakat Dec 16 '18 at 14:00

1 Answers1

2

According to documentation the CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_TIME_LAPSE_QVGA) may return true for unsupported resolution.

To ensure a given resolution is supported in LEGACY mode, the configuration given in CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP must contain the the resolution in the supported output sizes.

CamCorderProfile(int cameraId, int quality);

e.g:

CamcorderProfile.hasProfile(CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY,
            CamcorderProfile.QUALITY_TIME_LAPSE_QVGA)

And In order to get the camera ID list so you can get supported camera ID list, you can do as follow:

CameraManager cManager = (CameraManager) this.getApplicationContext().getSystemService(CAMERA_SERVICE);

Also the recommended way to check this is with StreamConfigurationMap.getOutputSizes(Class) with the class of the desired recording endpoint, and check that the desired resolution is contained in the list returned.

Sample of supported endpoint classes here.