android - MediaRecorder start failing -
i start failed: -19
when try run following code, pretty sure have elements need begin video capture, have surfaceview set camera preview , below rest of code initialized in
@override public void surfacecreated( surfaceholder surfaceholder )
i e/mediarecorder﹕ start failed: -19
when trying run method starts recorder. there else need add before starting actual recorder?
if(mcamera == null) { mcamera = camera.open(); mcamera.unlock(); } if(mrecorder == null) mrecorder = new mediarecorder(); try { mrecorder.setcamera( mcamera ); mrecorder.setvideosource(mediarecorder.videosource.camera); mrecorder.setaudiosource(mediarecorder.audiosource.mic); mrecorder.setoutputformat(mediarecorder.outputformat.mpeg_4); //audio mrecorder.setaudioencoder(mediarecorder.audioencoder.amr_nb); //video mrecorder.setvideoencoder(mediarecorder.videoencoder.mpeg_4_sp); mrecorder.setvideosize(640, 480); mrecorder.setvideoframerate( 15 ); mrecorder.setoutputfile( createnewfile() ); mrecorder.setpreviewdisplay( mholder.getsurface() ); mrecorder.setmaxduration(10000); } catch (exception e) { log.e( getstring( r.string.app_name ), "failed open camera" ); e.printstacktrace(); }
then in button click method have mrecorder.prepare();mrecorder.start();
.
edit
now getting error when try start recorder e/mediarecorder﹕ start failed: -2147483648
after setting video encoder before setting size.
another observation, have call startpreview()
on camera object before starting recorder?
there few things wrong or missing:
mcamera.unlock()
missing. has done before set camera in media recorder.- you have set video encoder before set video size.
mrecorder.setvideosize(640, 460)
not work on devices. assuming want set vga formatmrecorder.setvideosize(640, 480)
assumes camera supports video in vga format. cameras not all. find out video size supported need checkmcamera.getparameters().getsupportedvideosizes()
, in case function returns null pointer need checkmcamera.getparameters().getsupportedpreviewsizes()
.
Comments
Post a Comment