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. onActivityResult and the Settings Menu

Hi Everyone,

My app requires a network connection so if they don't have one enabled
I prompt them to start it.  I do this by calling the Wireless &
Network settings Activity as such:

startActivityForResult(new
Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS),
NETWORK_RESULT);

However, when I run my app in the de{*filter*}, onActivityResult is called
immediately as my calling activity is exited when it should be called
once the settings menu if exited.  This premature call also sends a
resultCode of Activity.RESULT_CANCEL.  Here is the code from
onActivityResult:

if (resultCode == Activity.RESULT_OK) {
                switch (requestCode) {
                case NETWORK_RESULT:
                        if (!mobileInfo.isConnected() && 
!wifiInfo.isConnected())
                                noNetwork();
                        else
                                do_something();
                }
}

Does anyone know if I'm doing something wrong?  If I understand this
correctly, onActivityResult should be the callback to when the
Wireless & Network Settings activity exits.

-- 

2. Saving SMS to SENT messages

Hello,
I have developed a simple application that on certain events sends an
SMS to ppl from my address book.
All works perfectly EXCEPT there is no trace of the SMS sent.
I know that the SMS gets delivered - I have tested it but eventually I
would like to have a trace of what was sent.
I have tried giving write permission but it didn't help.
Is there something special I have to do?
Thanks,
Suzann

-- 

3. Test for Camera Button hardware ?

4. Add Images to Jar files

5. onRestoreInstanceState exception only on froyo for a simple textview

6. Thoughts on this LenientPolicy implementation of an LVL Policy?

7. pinch-zoom image displayed in gallery