Android record video into a circular buffer and storing it in RAM

梦想的初衷 提交于 2019-12-08 12:59:38

问题


Im looking for a easy way to record video (including audio) into a circular buffer stored in RAM.

So I can leave the video recording it will keep the feed in RAM the last 2 minutes and then have the option to commit it to memory if required.

Unfortunately, I cannot see an easy way to do this. So far I have investigated using:

  • MediaRecorder - I could not see a way to store the output data in a buffer. Only option is setOutputFile()

  • JavaCV FFmpegFrameRecorder - again the constructor for this requires passing in a file.

  • android.hardware.Camera.PreviewCallback - this gives a byte array for every frame which I could add to a buffer. However, this approach does not provide any audio data.

I feel like there must be a easy way to do this but so far I've not had much luck. Any help with this would be very appreciated.


回答1:


JavaCV offers cvCreateCameraCapture() to open an interface with the camera. This code demonstrates how to capture frames from the camera and display them on a window.

The interesting part resides in the while loop: every iteration of loop retrieves a single frame from the camera with cvQueryFrame(). Note that the data type returned by this function is IplImage, and this type is responsible for storing the image grabbed from the camera.

All you need to do is store the IplImage returned by cvQueryFrame() in your circular buffer.



来源:https://stackoverflow.com/questions/20277255/android-record-video-into-a-circular-buffer-and-storing-it-in-ram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!