Reputation: 1
When trying to port some code to Android 4 (4.0.3/Nexus S) we found an issue with the MediaRecorder, I have attached the stacktrace. The same code worked without any problems on the same device running Android 2.3.x.
I'd be thankful for ideas.
Code:
MediaRecorder testRecorder = new MediaRecorder();
testRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
testRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
testRecorder.setVideoFrameRate(10);
testRecorder.setVideoSize(width, height);
testRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
testRecorder.setPreviewDisplay(recorderHolder.getSurface());
String videoPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/ streamer";
testRecorder.setOutputFile(videoPath + "/" + fileName);
try {
testRecorder.prepare();
} catch (IOException e) {
e.printStackTrace();
Log.e("comptest", "Recording of video failed.");
return false;
}
// start video for one second
testRecorder.start();
Stacktrace:
02-14 01:58:44.058: I/MediaRecorderJNI(16719): prepare:
surface=0x1f0dc80 (identity=3717)
02-14 01:58:44.379: E/MediaRecorder(16719): start failed: -19
02-14 01:58:44.386: D/AndroidRuntime(16719): Shutting down VM
02-14 01:58:44.386: W/dalvikvm(16719): threadid=1: thread exiting with
uncaught exception (group=0x40a771f8)
02-14 01:58:44.425: E/AndroidRuntime(16719): FATAL EXCEPTION: main
02-14 01:58:44.425: E/AndroidRuntime(16719):
java.lang.RuntimeException: start failed.
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.media.MediaRecorder.start(Native Method)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
de.tu.tk.zap.ui.stream.CameraRecorder.start(CameraRecorder.java:91)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
de.tu.tk.zap.ui.views.record.RecordActivity.startStreaming(RecordActivity.java:
337)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
de.tu.tk.zap.ui.views.record.RecordActivity.surfaceCreated(RecordActivity.java:
287)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.view.SurfaceView.updateWindow(SurfaceView.java:533)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.view.SurfaceView.access$000(SurfaceView.java:81)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.view.SurfaceView$3.onPreDraw(SurfaceView.java:169)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:
590)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1617)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.os.Handler.dispatchMessage(Handler.java:99)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.os.Looper.loop(Looper.java:137)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
android.app.ActivityThread.main(ActivityThread.java:4424)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
java.lang.reflect.Method.invokeNative(Native Method)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
java.lang.reflect.Method.invoke(Method.java:511)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-14 01:58:44.425: E/AndroidRuntime(16719): at
dalvik.system.NativeStart.main(Native Method)
Upvotes: 0
Views: 400
Reputation: 203
I faced similar problem, and I had to rewrite the whole video recorder. It seems to be a problem with OS
Upvotes: 1