L M
L M

Reputation: 136

Camera2 and Mediarecorder outputting high quality preview but low qualtiy mp4

Deleted and re-asked for clarity and better explanation.

Below is the code for my application, with an attached image. The video frame-rate is fine, however frames are very low quality and it seems to be low bitrate however editing the bitrate changes nothing on the video feed, which makes me think it's another issue. Anyone had this problem before?

private int videoQuality = 100000;
private int videoFramerate = 30;

private void setupMediaRecorder() throws IOException {
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mediaRecorder.setOutputFile(videoFileName); //timestamp.mp4
    mediaRecorder.setVideoEncodingBitRate(videoQuality);
    mediaRecorder.setVideoFrameRate(videoFramerate);
    mediaRecorder.setVideoSize(videoSize.getWidth(), videoSize.getHeight());
    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
    mediaRecorder.setOrientationHint(totalRotation);
    mediaRecorder.prepare();
}

preview screenshot preview screenshot

recordingscreenshot preview screenshot

recording - motion screenshot preview screenshot

Upvotes: 1

Views: 539

Answers (1)

L M
L M

Reputation: 136

Turns out 1000000 bitrate was too low, changed to 10000000 and looking fine.

Upvotes: 1

Related Questions