11

Can android MediaRecorder capture video with resolution higher than 320*240?

When I used MediaRecorder::setVideoSize() to set the video size, the captured video were all at the resolution of 320*240. Whats even worse, the higher ones can not get a clear video, they were somehow greenish. (encoder used is h263, format is mpeg4)

Android version used here is 1.6

Could you please anyone help me out?

Jonas
  • 121,568
  • 97
  • 310
  • 388
user483135
  • 111
  • 1
  • 1
  • 3

2 Answers2

9

I had an issue similar to what is described here. I turned out that I had to restructure my code slightly before I could adjust the video size.

The important thing is that setVideoSize() is called before setVideoEncoder(). I can't find this in the documentation, however it solved my problems with setting a specific video resolution. Also keep in mind that setOutputFormat() should be called before setVideoSize().

As as side note the same is true for setVideoFrameRate(). If it is not called before setVideoEncoder() it will not have any affect.

This was tested with Android 2.3.3

Here is a code example:

recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoSize(640,480);
recorder.setVideoFrameRate(30);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);       
Lasse Samson
  • 1,752
  • 3
  • 18
  • 17
3

First you are going to want to determine what your Camera supports. Try:

            List<String> anti = params.getSupportedAntibanding(); 
    List<String> color = params.getSupportedColorEffects();
    List<String> focus = params.getSupportedFocusModes(); 
    List<String> flash = params.getSupportedFlashModes();
    List<Size> previewSize = params.getSupportedPreviewSizes();
    List<Size> sizes = params.getSupportedPictureSizes();
    List<Integer> frameRates = params.getSupportedPreviewFrameRates();
    List<Integer> pictureFormats = params.getSupportedPictureFormats();
    List<String> scene = params.getSupportedSceneModes(); 
    List<String> white = params.getSupportedWhiteBalance();

This will tell you all of the Camera's supported parameters. Second Make sure that you initialize your MediaRecorder properly see the google documentation for the order in which you need to set the MediaRecorder. Also, if your Camera.setPreviewSize and MediaRecorder.setVideoSize are different it can cause odd behavior.

esse
  • 394
  • 1
  • 2
  • 9
  • i just hope they would write it (about VideoSize and PreviewSize) on their API documentation. – artsylar Aug 19 '11 at 03:31
  • isn't setVideoSize() just calls setPreviewSize()? Meaning, they will still have the same value in the end as long as the videosize is one of the supported preview sizes. – artsylar Aug 20 '11 at 01:35
  • params is an instance of Camera.Parameters (http://developer.android.com/reference/android/hardware/Camera.Parameters.html), accessed by calling camera.getParameters() – d2vid Jul 15 '14 at 22:58