Java Question Mediarecorder and preview frame

ribber

Member
Licensed User
Longtime User
Hi all,

I'm currently developing a libary that has realtime access to the camera preview while recording with the android mediarecorder a video. The problem is: Once the record process of the mediarecorder is started, the onPreviewFrame(byte[] data, Camera camera) event is not longer triggered.

I found a possible solution at stackoverflow but this is not working for me.

B4X:
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    mCamera.setPreviewCallback(new PreviewCallback() {
            public void onPreviewFrame(byte[] _data, Camera _camera) {
                Log.d("onPreviewFrame-surfaceChanged",String.format("Got %d bytes of camera data", _data.length));
            }
        });

}
Could you please help with this problem?

Thank you!
 
Last edited:

ribber

Member
Licensed User
Longtime User
Thank you Erel for your answer. I saw this event in your camera libary. The issue is that onPreviewFrame seems to be never called while recording a video with the mediarecorder. Is this "only" a multithreading problem?

I'm searching for a solution to record a video on a local device AND display a preview on a remote device at the same time. My current approach is:

1. Record video using mediarecorder.
2. Use onPreviewFrame to stream bytes() of the preview to a remote device (like Android based Closed Circuit TV (CCTV) example).

Step 2 is not working because of the above mentioned problems.

Do you have any recommendations/alternatives or solutions?

Thank you!
 
Top