android - MediaRecorder.stop() stop failed: -1007 -
i recording video mediarecorder. code works fine on 2.3.3 fails on 4.0.3.
the issue following: code mediarecorder.stop() throws runtimeexeption
java.lang.runtimeexception: stop failed. @ android.media.mediarecorder.stop(native method)
with logcat message
04-05 15:10:51.815: e/mediarecorder(15709): stop failed: -1007
update
i've found, mediaplayer reports error (via mediaplayer.onerrorlistener) after start. error code 100 (media server died), -1007.
update 2 code prepare mediarecorder
c = camera.open(); ... // step 1: unlock , set camera mediarecorder camera.unlock(); mediarecorder.setcamera(camera); // step 2: set sources mediarecorder.setaudiosource(mediarecorder.audiosource.camcorder); mediarecorder.setvideosource(mediarecorder.videosource.camera); // step 3: set camcorderprofile (requires api level 8 or higher) camcorderprofile profile = camcorderprofile .get(camcorderprofile.quality_high); // manual set up! mediarecorder.setoutputformat(mediarecorder.outputformat.mpeg_4); mediarecorder.setvideoencodingbitrate(profile.videobitrate); mediarecorder.setvideoframerate(profile.videoframerate); mediarecorder.setvideosize(profile.videoframewidth, profile.videoframeheight); mediarecorder.setaudiochannels(profile.audiochannels); mediarecorder.setaudioencodingbitrate(profile.audiobitrate); mediarecorder.setaudiosamplingrate(profile.audiosamplerate); mediarecorder.setaudioencoder(profile.audiocodec); //mediarecorder.setvideoencoder(mediarecorder.videoencoder.mpeg_4_sp); mediarecorder.setvideoencoder(profile.videocodec); // mediarecorder.setprofile(profile); // step 4: set output file mediarecorder.setoutputfile("somefile.mp4"); // step 5: set preview output mediarecorder.setpreviewdisplay(preview.getholder().getsurface()); // step 6: prepare configured mediarecorder try { mediarecorder.prepare(); } catch ... { release mediarecorder}
then simplycall mediarecorder.start() please note, need video encoded mp4 format. code works on samsng galaxy gio (android 2.3.3) , fails described on acer e305 (android 4.0.2)
any ideas? thanks.
solved @ last. issue setting preview size before setting actual preview camera. preview size must equal selected video size.
camcorderprofile profile = [get required profile]; camera.parameters parameters = mcamera.getparameters(); parameters.setpreviewsize(profile.videoframewidth,profile.videoframeheight); mcamera.setparameters(parameters); mcamera.setpreviewdisplay([surface holder]); mcamera.startpreview(); ... //configure mediarecorder , call mediarecorder.start()
Comments
Post a Comment