I would like to give the users an option to set different resolutions.
I've tried this solution
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
....
....
mCamera.unlock();
recorder.setCamera(mCamera);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setProfile(camcorderProfile);
It worked perfectly: nice quality and everything...
When I set it to
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
with FLASH on, the video came out with greenish and some other weird colors.
I read online and people said it is because QUALITY_480P is probably not supported on my phone. Ok, it makes senses.
Therefore, I started working on the different solution, so I've tried....
recorder.setVideoSize(640, 480);
It worked great,
but the video looked VERY ugly.
Next, I checked for a supported video list.
List<Size> GetSupportedVideosResolutions = params.getSupportedVideoSizes();
Resolution: 1280x720 is in the list, so
I've tried to set the following:
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoSize(1280,720);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
It gave me a RuntimeException error.
The question is
Why can't it let me set the higher resolutions that are available on the phone?
Any help would be greatly appreciated,
Thank you.
Edit: added error log
04-18 17:40:07.391: E/AndroidRuntime(30191): java.lang.RuntimeException: start failed.
04-18 17:40:07.391: E/AndroidRuntime(30191): at android.media.MediaRecorder.start(Native Method)
04-18 17:40:07.391: E/AndroidRuntime(30191): at test.com.VideoActivity.prepare_StartRecorder(VideoActivity.java:1009)
04-18 17:40:07.391: E/AndroidRuntime(30191): at test.com.VideoActivity.Recorder_Start_Stop(VideoActivity.java:1102)
04-18 17:40:07.391: E/AndroidRuntime(30191): at test.com.VideoActivity$6.onClick(VideoActivity.java:246)
04-18 17:40:07.391: E/AndroidRuntime(30191): at android.view.View.performClick(View.java:4489)
04-18 17:40:07.391: E/AndroidRuntime(30191): at android.widget.CompoundButton.performClick(CompoundButton.java:104)
04-18 17:40:07.391: E/AndroidRuntime(30191): at android.view.View$PerformClick.run(View.java:18803)
04-18 17:40:07.391: E/AndroidRuntime(30191): at android.os.Handler.handleCallback(Handler.java:730)
04-18 17:40:07.391: E/AndroidRuntime(30191): at android.os.Handler.dispatchMessage(Handler.java:92)
04-18 17:40:07.391: E/AndroidRuntime(30191): at android.os.Looper.loop(Looper.java:137)
04-18 17:40:07.391: E/AndroidRuntime(30191): at android.app.ActivityThread.main(ActivityThread.java:5493)
04-18 17:40:07.391: E/AndroidRuntime(30191): at java.lang.reflect.Method.invokeNative(Native Method)
04-18 17:40:07.391: E/AndroidRuntime(30191): at java.lang.reflect.Method.invoke(Method.java:525)
04-18 17:40:07.391: E/AndroidRuntime(30191): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
04-18 17:40:07.391: E/AndroidRuntime(30191): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
04-18 17:40:07.391: E/AndroidRuntime(30191): at dalvik.system.NativeStart.main(Native Method)
I figured what the problem was. This may help someone else. I ended up with:
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
recorder.setVideoSize(1280, 720); //NEEDED or it will crash
Code:
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
....
....
mCamera.unlock();
recorder.setCamera(mCamera);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setProfile(camcorderProfile);
recorder.setVideoSize(1280 720); //NEEDED or it will crash
....
...
//or
CamcorderProfile.get(CamcorderProfile.QUALITY_1080P);
recorder.setProfile(camcorderProfile);
recorder.setVideoSize(1920, 1080); //NEEDED or it will crash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With