I'm currently using onPreviewCallback so I can capture frames from camera when in preview and stream them via http.
That works but then I issue a command to start recording and, it seems, I do not have a preview callback anymore.
So, how do I keep the preview callback so I can both send the frames from the surface to my server AND record the video on the device?
I didn't work for quite long time with Android Camera. However, as I remember
1) onPreviewCallback isn't called while you are recording
It's mentioned in couple of questions:
Camera onPreviewFrame not called How to show real time filtered camera preview while recording videos?
2) I saw that it was handled in SipDroid and couple of other Android SIP clients following way (this was a 1-2 years ago, so this method could be outdates):
3) You can use onPreviewFrame + start AudioRecorder and encode it yourself (using ffmpeg or something like that) to mp4 file. This way you don't need to start MediaRecorder recording.
You can call these methods after your media recorder.start() being called as following :
camera.reconnect();
camera.setPreviewCallback();
surfaceview.getHolder().addCallback();
The reasons:
I have ever been the same issue as yours in my application, and i fixed it by this. Hope it can resolve your problems!
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