From 7f43a4a10b2d5f383602e9f5745fbc5bc8b69cb8 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Fri, 14 Sep 2018 16:46:11 +0300 Subject: [PATCH] Fixed Exception on some devices when we use default videoCodec instead CamcorderProfile videoCodec. (#264) Looks like passing camcorderProfile.videoCodec instead of MediaRecorder.VideoEncoder.DEFAULT avoids some exceptions. --- .../src/main/java/com/otaliastudios/cameraview/Camera1.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index 6ff4347a..6721572b 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -688,7 +688,11 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera mMediaRecorder.setOutputFormat(profile.fileFormat); mMediaRecorder.setVideoFrameRate(profile.videoFrameRate); mMediaRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight); - mMediaRecorder.setVideoEncoder(mMapper.map(mVideoCodec)); + if (mVideoCodec == VideoCodec.DEFAULT) { + mMediaRecorder.setVideoEncoder(profile.videoCodec); + } else { + mMediaRecorder.setVideoEncoder(mMapper.map(mVideoCodec)); + } mMediaRecorder.setVideoEncodingBitRate(profile.videoBitRate); if (mAudio == Audio.ON) { mMediaRecorder.setAudioChannels(profile.audioChannels);