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. Is there a way for an application to know whether it has been downloaded from Market?

Currently the platform knows absolutely nothing about where an installed app
came from.  There may be an API you can use with the market to find out if
it had installed your app at some point, but I doubt such a thing exists
right now.






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

2. Change MAIN LAUNCHER activity doesn't "take"

The system doesn't cache anything about the contents of manifests across
boots, so there is no way this can just not work.

One thing that can happen is that when you make a shortcut on the home
screen, this does of course reference the explicit component the shortcut is
for.  So if the application is changed such that the component no longer
exists, you will need to delete the current shortcut and make a new one.








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

3. Analyzed and fixed "...acore has stopped unexpectedly" issue

4. Installing the ADT plugin for Eclipse with only the command line.

5. T-Mobile plans Android-based home devices

6. How to troubleshoot a Stackoverflow error in android ViewRoot?

7. Different APNs