prepare() fails when trying to record video

by Magnus » Fri, 04 Sep 2009 22:38:30 GMT


Sponsored Links
 i, tried to make a simple camcorder application based on the
VideoCamera in the default apps. My main problem is that the prepare()
call always fail.
I am pretty sure I set all the settings in the MediaRecorder correctly
and in the right order.
..
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.MPEG_4_SP);
recorder.setOutputFile("/sdcard/video_test.mp4");
..
when surface is created i do:
recorder.setPreviewDisplay(holder.getSurface());
if (recorder != null) {
try {
recorder.prepare();
} catch (IllegalStateException e) {
Log.e("IllegalStateException", e.toString(), e);
} catch (IOException e) {
Log.e("IOException", e.toString(), e);
}
}

However, the prepare always fail. When I view logcat I see the
following error:
E/MediaRecorder( 222): prepare failed: -2147483648

E/IOException( 223): java.io.IOException: prepare failed.
E/IOException( 223): java.io.IOException: prepare failed.
E/IOException( 223): at android.media.MediaRecorder._prepare(Native
Method)
E/IOException( 223): at android.media.MediaRecorder.prepare
(MediaRecorder.java:375)
E/IOException( 223): at
com.mycompany.CamcorderPreview.surfaceCreated(CamcorderPreview.java:
41)
E/IOException( 223): at android.view.SurfaceView.updateWindow
(SurfaceView.java:352)
E/IOException( 223): at android.view.SurfaceView.dispatchDraw
(SurfaceView.java:259)
E/IOException( 223): at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/IOException( 223): at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/IOException( 223): at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/IOException( 223): at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/IOException( 223): at android.view.View.draw(View.java:5841)
E/IOException( 223): at android.widget.FrameLayout.draw
(FrameLayout.java:352)
E/IOException( 223): at android.view.ViewGroup.drawChild
(ViewGroup.java:1486)
E/IOException( 223): at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/IOException( 223): at android.view.View.draw(View.java:5841)
E/IOException( 223): at android.widget.FrameLayout.draw
(FrameLayout.java:352)
E/IOException( 223): at com.android.internal.policy.impl.PhoneWindow
$DecorView.draw(PhoneWindow.java:1847)
E/IOException( 223): at android.view.ViewRoot.draw(ViewRoot.java:
1217)
E/IOException( 223): at android.view.ViewRoot.performTraversals
(ViewRoot.java:1030)
E/IOException( 223): at android.view.ViewRoot.handleMessage
(ViewRoot.java:1482)
E/IOException( 223): at android.os.Handler.dispatchMessage
(Handler.java:99)
E/IOException( 223): at android.os.Looper.loop(Looper.java:123)
E/IOException( 223): at android.app.ActivityThread.main
(ActivityThread.java:3948)
E/IOException( 223): at java.lang.reflect.Method.invokeNative
(Native Method)
E/IOException( 223): at java.lang.reflect.Method.invoke(Method.java:
521)
E/IOException( 223): at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/IOException( 223): at com.android.inte



Other Threads

1. No com.android.camera.CropImage on HTC Magic?

Hi,

I have a pretty urgent issue. I am using the CropImage intent on my G1 Dev
phone to crop images.
However when starting this intent on a HTC Magic I get an error indicating
the activity cannot be found:

"Unable to find explicit activity class
{com.android.camera/com.android.camera.CropImage}"

Why is this activity not present on HTC Magic?
Any input is much appreciated.

Best regards,

--~--~---------~--~----~------------~-------~--~----~

2. How does ResolverActivity or ChooserActivity getting launched?

Thank you.

Is it possible to substitute the Choose Activity?






--~--~---------~--~----~------------~-------~--~----~

3. URGENT! map api key after signing an app?

4. DDMS under Mac OS X 10.5 (Snow Leopoard)

5. settingan mms

6. Very simple question about the HTC phones with trackballs (like the G1)

7. BroadcastReceiver to listen incoming call