Error handling: Android.media.MediaRecorder.start (Native Method) Error: Start failed:-19

Source: Internet
Author: User

spydroid-android test Reporting errors in android4.0 system [HTML]View PlainCopy
    1. Start failed:-19

And also found that in the use of Mediarecorder for video recording, call Start () method times wrong, the occurrence of spydroid-android test on the android4.0 system the same error, the specific error is as follows:

[HTML]View PlainCopy
  1. 01-06 14:04:07.790:v/mediarecorder (13280): Prepare
  2. 01-06 14:04:07.790:v/imediarecorder (13280): Prepare
  3. 01-06 14:04:07.800:v/mediarecorder (13280): Start
  4. 01-06 14:04:07.800:v/imediarecorder (13280): Start
  5. 01-06 14:04:08.190:e/mediarecorder (13280): Start failed:-19
  6. 01-06 14:04:08.190:w/system.err (13280): Java.lang.RuntimeException:start failed.
  7. 01-06 14:04:08.200:w/system.err (13280): at Android.media.MediaRecorder.start (Native Method)
  8. 01-06 14:04:08.200:w/system.err (13280): at Com.yousee.videocapturedemo.videocaptureplus$2.onclick ( videocaptureplus.java:145)
  9. 01-06 14:04:08.200:w/system.err (13280): at Android.view.View.performClick (view.java:3515)
  10. 01-06 14:04:08.200:w/system.err (13280): at Android.view.view$performclick.run (view.java:14144)
  11. 01-06 14:04:08.200:w/system.err (13280): at Android.os.Handler.handleCallback (handler.java:605)
  12. 01-06 14:04:08.200:w/system.err (13280): at Android.os.Handler.dispatchMessage (handler.java:92)
  13. 01-06 14:04:08.200:w/system.err (13280): at Android.os.Looper.loop (looper.java:148)
  14. 01-06 14:04:08.200:w/system.err (13280): at Android.app.ActivityThread.main (activitythread.java:4503)
  15. 01-06 14:04:08.200:w/system.err (13280): at Java.lang.reflect.Method.invokeNative (Native Method)
  16. 01-06 14:04:08.200:w/system.err (13280): at Java.lang.reflect.Method.invoke (method.java:511)
  17. 01-06 14:04:08.200:w/system.err (13280): at Com.android.internal.os.zygoteinit$methodandargscaller.run ( zygoteinit.java:830)
  18. 01-06 14:04:08.200:w/system.err (13280): at Com.android.internal.os.ZygoteInit.main (zygoteinit.java:597)
  19. 01-06 14:04:08.200:w/system.err (13280): at Dalvik.system.NativeStart.main (Native Method)


The Mediarecorder initialization and setup code is as follows:

[Java]View PlainCopy
  1. .....
  2. mmediarecorder=new Mediarecorder ();
  3. //Set Video source
  4. Mmediarecorder.setvideosource (MediaRecorder.VideoSource.DEFAULT);
  5. //Set audio source
  6. Mmediarecorder.setaudiosource (MediaRecorder.AudioSource.DEFAULT);
  7. //Set file output format
  8. Mmediarecorder.setoutputformat (MediaRecorder.OutputFormat.THREE_GPP);
  9. //Set video encoding mode
  10. Mmediarecorder.setvideoencoder (MediaRecorder.VideoEncoder.H264);
  11. //Set audio encoding mode
  12. Mmediarecorder.setaudioencoder (MediaRecorder.AudioEncoder.DEFAULT);
  13. //Set the video height and width, note the description of the document:
  14. //must is called after Setvideosource ().
  15. //call this after Setoutformat () but before prepare ().
  16. //Set the recorded video frame rate, note the description of the document:
  17. //must is called after Setvideosource ().
  18. //call this after Setoutformat () but before prepare ().
  19. Mmediarecorder.setvideoframerate (20);
  20. //Set preview screen
  21. Mmediarecorder.setpreviewdisplay (Msurfaceholder.getsurface ());
  22. //Set Output path
  23. Mmediarecorder.setoutputfile
  24. (Environment.getexternalstoragedirectory () +file.separator+system.currenttimemillis () +". mp4");
  25. .....
  26. Mediarecorder.prepare ();
  27. Mediarecorder.start ();
  28. .....
[Java]View PlainCopy

The same program runs normally on the Android2.3 platform, and the error is reported in Android4.0.

Workaround:

Comment out the statement that sets the video frame rate. Mmediarecorder.setvideoframerate (mquality.framerate);

After removing the setvideoframerate, if the error still occurs, you can

Mmediarecorder.setvideosize (Videowidth, Videoheight), also commented out

Reason:

The video's frame rate and video size are hardware-supported, and if the frame rate and video size are set, an error occurs if the hardware is not supported.

Reference:

Http://stackoverflow.com/questions/11249642/mediarecorder-start-failed-19

Error handling: Android.media.MediaRecorder.start (Native Method) Error: Start failed:-19

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.