Android: Modifying recorded video quality

前端 未结 3 1757
轮回少年
轮回少年 2021-01-13 17:03

I\'m using MediaRecorder to record a video. It isn\'t clear to me what parameters I should be using to change the quality of the image, assuming the size of the video remain

相关标签:
3条回答
  • try this one u can solve problem

    mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); 
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    
    String path = Environment.getExternalStorageDirectory() + "/file.mp4";
    mediaRecorder.setOutputFile(path);
    
    0 讨论(0)
  • 2021-01-13 17:50

    You have to increase video encoding bit rate to increase the video quality using setVideoEncodingBitRate() in MediaRecorder.

    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    

    mRecorder.setVideoEncodingBitRate(4000000);`

    0 讨论(0)
  • 2021-01-13 18:06

    You can try using

    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);
    

    or

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

    For setting high quality and low quality parameter see here

    0 讨论(0)
提交回复
热议问题