When calling stop()
within my Video Capture activity, on occasion, the software will hang and will not come back to life. Only triggering an ANR by hitting "Back" will allow me to kill the activity.
Within the log, I see the following line repeated over and over:
W/CameraSource(YYYYY): Timed out waiting for incoming camera video frames: XXXXXX us
Has anyone else seen this behavior? Any workarounds?
We've been struggling for this issue for a long time too. We have just copied the code from android developer site for capturing video but the application hangs before mediarecorder.stop() is called. Upon debugging almost line by line, I found out the ff. line causes the issue:
captureButton.setText("start");
I have commented it out and stopping the mediarecorder will no longer cause an ANR. What I did was instead of changing the text of the button, I just change the background.
captureButton.setBackgroundResource(R.drawable.icon_post_camera_record_main);
Without seeing your code, I'm not sure if we have the same cause of the issue but this fixes mine. I'm still searching why this happens for settext() and not for setBackgroundResource. My guess is that it has something to do with background/async task but it's still a guess.
This also happened to me because I was releasing the camera before performing stop() on the recorder. It also explains the error message "Timed out waiting for incoming camera video frames". It's waiting for a camera that is already released. Make sure to stop the recorder - and only then release the camera:
mMediaRecorder.stop();
mMediaRecorder.release();
camera.stopPreview();
camera.release();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With