Unable to set video quality for media recorder. Video Produces Flickering Video

mMediaRecorder = new MediaRecorder();
    // Step 1: Unlock and set camera to MediaRecorder
    mCamera.unlock();
    mMediaRecorder.setCamera(mCamera);
    // Step 2: Set sources
    // activate this for recording with sound\

    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

    mMediaRecorder.setVideoSize(getMaxSupportedVideoSize().width,getMaxSupportedVideoSize().height);

    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    // Step 4: Set output file
    mMediaRecorder.setOutputFile(getOutputMediaFile("movie"));

    // Step 4: Set output file
    mMediaRecorder.setOutputFile(getOutputMediaFile("movie"));


    // Step 5: Set the preview output
    mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());

    mMediaRecorder.setOrientationHint(90);

the above code works fine But the video quality is not the same as the video that I shoot on my own android camera, my video recorded using a media recorder is poor compared to the original one, how can I improve the quality of the video.

If anyone knows, help me. thank

+4
source share
3 answers

I'm not a Java / Android developer, I use Xamarin and C #, but I had the same problem and my solution should be directly applicable (even the syntax is almost identical).

, setCamera ( , , ), mediaRecorder.

, mediaRecorder.start(), , , .

, , , MediaRecorder , , .

  • ,
  • .
  • MediaRecorder ( setCamera)
  • MediaRecorder
  • .

, , , .

, , mediaRecorder.setCamera(), :

mCamera.stopPreview(); mCamera.setPreviewDisplay(null);

,

mRecorder.setCamera()

. 720p ( 1080p), .

, , .

, ,

mCamera.setPreviewDisplay(mPreview.getHolder().getSurface())

, , .

, :)

+2

1

recorder.setVideoSize(640, 480);
recorder.setVideoFrameRate(16); //might be auto-determined due to lighting
recorder.setVideoEncodingBitRate(3000000);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);// MPEG_4_SP
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

2

CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
recorder.setProfile(cpHigh);
+1

:

    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

mMediaRecorder.setVideoSize(getMaxSupportedVideoSize() , getMaxSupportedVideoSize() ..);

mMediaRecorder.setVideoEncoder (MediaRecorder.VideoEncoder.H264); mMediaRecorder.setAudioEncoder (MediaRecorder.AudioEncoder.AMR_NB);

with:

    mMediaRecorder.setProfile(CamcorderProfile
            .get(CamcorderProfile.QUALITY_HIGH));
+1
source

Source: https://habr.com/ru/post/1543366/


All Articles