Android MediaRecorder prepare failed -17
<p>I am trying to capture video and encode it using Android <code>MediaRecorder</code>.But when I am getting<br>
prepare failed: </p>

<pre><code>-17
java.io.IOException: prepare failed.
</code></pre>

<p>Here is my code:</p>

<pre><code>mediaRecorder = new MediaRecorder();
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setOutputFile("/sdcard/test.mp4");
mediaRecorder.setVideoFrameRate(20);
mediaRecorder.setVideoSize(176, 144);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.prepare();
</code></pre>

<p><strong>When i set VideoEncoder to H263 and Outputformat to THREE_GPP i am not getting this exception</strong>.</p>

<p>Here is the complete stacktrace.</p>

<pre><code>E/mm-camera 7x-vfe(   68): Received VFE start ACK!!! This is a user preview start.

D/QualcommCameraHardware(   68): startPreview X
E/AuthorDriver(   68): Command 13 completed with error -17
E/MediaRecorder( 6406): prepare failed: -17
W/System.err( 6406): java.io.IOException: prepare failed.
W/System.err( 6406):    at android.media.MediaRecorder._prepare(Native Method)
W/System.err( 6406):    at android.media.MediaRecorder.prepare(MediaRecorder.java:509)
W/System.err( 6406):    at org.video.VideoStreamSender.prepare(VideoStreamSender.java:50)
W/System.err( 6406):    at org.video.VideoPreview.surfaceCreated(VideoPreview.java:50)
W/System.err( 6406):    at android.view.SurfaceView.updateWindow(SurfaceView.java:540)
W/System.err( 6406):    at android.view.SurfaceView.dispatchDraw(SurfaceView.java:339)
W/System.err( 6406):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
W/System.err( 6406):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
W/System.err( 6406):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
W/System.err( 6406):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
W/System.err( 6406):    at android.view.View.draw(View.java:6742)
W/System.err( 6406):    at android.widget.FrameLayout.draw(FrameLayout.java:352)
W/System.err( 6406):    at android.view.ViewGroup.drawChild(ViewGroup.java:1648)
W/System.err( 6406):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
W/System.err( 6406):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
W/System.err( 6406):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
W/System.err( 6406):    at android.view.View.draw(View.java:6742)
W/System.err( 6406):    at android.widget.FrameLayout.draw(FrameLayout.java:352)
W/System.err( 6406):    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1872)
W/System.err( 6406):    at android.view.ViewRoot.draw(ViewRoot.java:1422)
W/System.err( 6406):    at android.view.ViewRoot.performTraversals(ViewRoot.java:1167)
W/System.err( 6406):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1744)
W/System.err( 6406):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 6406):    at android.os.Looper.loop(Looper.java:143)
W/System.err( 6406):    at android.app.ActivityThread.main(ActivityThread.java:4914)
W/System.err( 6406):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 6406):    at java.lang.reflect.Method.invoke(Method.java:521)
W/System.err( 6406):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
W/System.err( 6406):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
W/System.err( 6406):    at dalvik.system.NativeStart.main(Native Method)
I/CameraService(   68): [Camera KPI] 1st preview frame
</code></pre>
