spydroid-android test Reporting errors in android4.0 system
[HTML]View PlainCopy
- 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
- 01-06 14:04:07.790:v/mediarecorder (13280): Prepare
- 01-06 14:04:07.790:v/imediarecorder (13280): Prepare
- 01-06 14:04:07.800:v/mediarecorder (13280): Start
- 01-06 14:04:07.800:v/imediarecorder (13280): Start
- 01-06 14:04:08.190:e/mediarecorder (13280): Start failed:-19
- 01-06 14:04:08.190:w/system.err (13280): Java.lang.RuntimeException:start failed.
- 01-06 14:04:08.200:w/system.err (13280): at Android.media.MediaRecorder.start (Native Method)
- 01-06 14:04:08.200:w/system.err (13280): at Com.yousee.videocapturedemo.videocaptureplus$2.onclick ( videocaptureplus.java:145)
- 01-06 14:04:08.200:w/system.err (13280): at Android.view.View.performClick (view.java:3515)
- 01-06 14:04:08.200:w/system.err (13280): at Android.view.view$performclick.run (view.java:14144)
- 01-06 14:04:08.200:w/system.err (13280): at Android.os.Handler.handleCallback (handler.java:605)
- 01-06 14:04:08.200:w/system.err (13280): at Android.os.Handler.dispatchMessage (handler.java:92)
- 01-06 14:04:08.200:w/system.err (13280): at Android.os.Looper.loop (looper.java:148)
- 01-06 14:04:08.200:w/system.err (13280): at Android.app.ActivityThread.main (activitythread.java:4503)
- 01-06 14:04:08.200:w/system.err (13280): at Java.lang.reflect.Method.invokeNative (Native Method)
- 01-06 14:04:08.200:w/system.err (13280): at Java.lang.reflect.Method.invoke (method.java:511)
- 01-06 14:04:08.200:w/system.err (13280): at Com.android.internal.os.zygoteinit$methodandargscaller.run ( zygoteinit.java:830)
- 01-06 14:04:08.200:w/system.err (13280): at Com.android.internal.os.ZygoteInit.main (zygoteinit.java:597)
- 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
- .....
- mmediarecorder=new Mediarecorder ();
- //Set Video source
- Mmediarecorder.setvideosource (MediaRecorder.VideoSource.DEFAULT);
- //Set audio source
- Mmediarecorder.setaudiosource (MediaRecorder.AudioSource.DEFAULT);
- //Set file output format
- Mmediarecorder.setoutputformat (MediaRecorder.OutputFormat.THREE_GPP);
- //Set video encoding mode
- Mmediarecorder.setvideoencoder (MediaRecorder.VideoEncoder.H264);
- //Set audio encoding mode
- Mmediarecorder.setaudioencoder (MediaRecorder.AudioEncoder.DEFAULT);
- //Set the video height and width, note the description of the document:
- //must is called after Setvideosource ().
- //call this after Setoutformat () but before prepare ().
- //Set the recorded video frame rate, note the description of the document:
- //must is called after Setvideosource ().
- //call this after Setoutformat () but before prepare ().
- Mmediarecorder.setvideoframerate (20);
- //Set preview screen
- Mmediarecorder.setpreviewdisplay (Msurfaceholder.getsurface ());
- //Set Output path
- Mmediarecorder.setoutputfile
- (Environment.getexternalstoragedirectory () +file.separator+system.currenttimemillis () +". mp4");
- .....
- Mediarecorder.prepare ();
- Mediarecorder.start ();
- .....
[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