I have to record a video with the resolution 640x360 (or convert to this size in some way). Then, I followed the example from Android Developer to implement my own camera activity to be able to set the settings I want. But, when I push the button to start recording the video, I get this exception:
12-09 19:30:18.679: E/MediaRecorder(8614): start failed: -19
12-09 19:30:36.476: E/AndroidRuntime(8614): FATAL EXCEPTION: main
12-09 19:30:36.476: E/AndroidRuntime(8614): java.lang.RuntimeException: start failed.
12-09 19:30:36.476: E/AndroidRuntime(8614): at android.media.MediaRecorder.start(Native Method)
12-09 19:30:36.476: E/AndroidRuntime(8614): at com.autosonvideo.CameraManagerActivity$3.onClick(CameraManagerActivity.java:99)
12-09 19:30:36.476: E/AndroidRuntime(8614): at android.view.View.performClick(View.java:3558)
12-09 19:30:36.476: E/AndroidRuntime(8614): at android.view.View$PerformClick.run(View.java:14157)
12-09 19:30:36.476: E/AndroidRuntime(8614): at android.os.Handler.handleCallback(Handler.java:605)
12-09 19:30:36.476: E/AndroidRuntime(8614): at android.os.Handler.dispatchMessage(Handler.java:92)
12-09 19:30:36.476: E/AndroidRuntime(8614): at android.os.Looper.loop(Looper.java:137)
12-09 19:30:36.476: E/AndroidRuntime(8614): at android.app.ActivityThread.main(ActivityThread.java:4514)
12-09 19:30:36.476: E/AndroidRuntime(8614): at java.lang.reflect.Method.invokeNative(Native Method)
12-09 19:30:36.476: E/AndroidRuntime(8614): at java.lang.reflect.Method.invoke(Method.java:511)
12-09 19:30:36.476: E/AndroidRuntime(8614): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
12-09 19:30:36.476: E/AndroidRuntime(8614): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
12-09 19:30:36.476: E/AndroidRuntime(8614): at dalvik.system.NativeStart.main(Native Method)
Then, I found out that this was the problem:
mMediaRecorder.setVideoSize(640,360);
If I change it to:
mMediaRecorder.setVideoSize(640,480);
Then, it works fine.
But I need a video in 640x360. Is there any way to do that? Or a way to "resize" a video from 1280x720 to 640x360?
It will run on Android 4.0 or higher.
Thanks in advance!
You cannot choose an arbitrary resolution -- it has to be one that the camera hardware supports. You find out the camera resolutions from
Camera.Parameters
.There is nothing built into Android designed to transcode a video into a different resolution. You are welcome to explore third-party options, such as
ffmpeg
.