Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video quality in android?

I am using the media recorder class for recording video, I initialize the recorder with following properties,

    recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

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

But the quality of video is not as same as video I shoot over native android camera, my video recorded using media recorder is of poor quality as compared to the native one, how can I improve the video quality.

If any one knows me help me out.Thanks

like image 451
Karthi Avatar asked Jun 21 '11 11:06

Karthi


People also ask

What is the best app to enhance video quality?

9 Best Apps to Enhance Video Quality on Android & iOS 1 InShot – Video Editor. InShot will help you to enhance any video as well as to create it from nothing. ... 2 VivaVideo. ... 3 Videoshop – Video Editor. ... 4 VideoShow Video Editor & Maker. ... 5 PowerDirector. ... 6 Splice – Video Editor & Maker. ... 7 KineMaster. ... 8 Quick. ...

How to find the resolution of a video on Android?

Finding Video Resolution on Android 1 Open the Gallery App and navigate to the videos section. 2 Select any video whose resolution you want to check. ... 3 The following screen will show all the information related to the selected video. ...

How can I improve the quality of my video?

Videoleap is a photo editing app that you can also try to use to increase the quality of your video. This can be achieved by using the standard process of video editing, e.g. applying filters, effects, converting the video, and so on. You can also change the resolution of the video when you are exporting it to your device.

Is it better to increase or decrease video resolution on Android?

It is also advisable that if you are not a professional that really needs the highest video resolution possible, it's better to always reduce video sizes on android to create more storage space for other files. This is because when you reduce video sizes on android, you also reduce bandwidth usage and uploading time.


2 Answers

Finally I found the code to record high quality video in android 2.1 by setting videEncodingBitRate , AudioEncodingBitRate, AudioSamplingRate ...etc. Using this method you can set the properties for video whatever you want to provide high quality video.

For setting high quality and low quality parameter refer this page,

http://www.andgps.com/20110410/camcorderprofile-predefined-camcorder-profile-settings-for-camcorder-applications

The code i used with base version android 2.1 to produce high quality video is shown below,

    recorder = new MediaRecorder();
    Method[] methods = recorder.getClass().getMethods();
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setVideoFrameRate(24);
    recorder.setVideoSize(720, 480);

    for (Method method: methods){
    try{
        if (method.getName().equals("setAudioChannels")){
                method.invoke(recorder, String.format("audio-param-number-of-channels=%d", 1));
        } 
        else if(method.getName().equals("setAudioEncodingBitRate")){
                method.invoke(recorder,12200);
            }
        else if(method.getName().equals("setVideoEncodingBitRate")){
            method.invoke(recorder, 3000000);
        }
        else if(method.getName().equals("setAudioSamplingRate")){
            method.invoke(recorder,8000);
        }
        else if(method.getName().equals("setVideoFrameRate")){
            method.invoke(recorder,24);
        }
    }catch (IllegalArgumentException e) {

        e.printStackTrace();
    } catch (IllegalAccessException e) {

        e.printStackTrace();
    } catch (InvocationTargetException e) {

        e.printStackTrace();
    }
    }

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

`

like image 108
Karthi Avatar answered Sep 19 '22 12:09

Karthi


use the following settings for Video Recordings:-

private void cameraSettings()
{
    mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
    mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
    mediaRecorder.setVideoSize(width, height);
    mediaRecorder.setVideoFrameRate(videoFramePerSecond);
}

use videoFramePerSecond = 30 and width = 1280 and height= 720.. This setting you can do by your own as per your requirment.

like image 40
Balban Avatar answered Sep 20 '22 12:09

Balban