Android将视频记录到循环缓冲区中并将其存储在RAM中 [英] Android record video into a circular buffer and storing it in RAM

查看:108
本文介绍了Android将视频记录到循环缓冲区中并将其存储在RAM中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种将视频(包括音频)记录到RAM中存储的循环缓冲区中的简便方法.

所以我可以保留视频记录,它将在最近2分钟内将提要保留在RAM中,然后根据需要选择将其提交到内存中.

不幸的是,我看不到一种简单的方法来做到这一点.到目前为止,我已经使用以下方法进行了调查:

  • MediaRecorder-我看不到将输出数据存储在 缓冲.唯一的选择是setOutputFile()

  • JavaCV FFmpegFrameRecorder-再次为此需要构造函数 传入文件.

  • android.hardware.Camera.PreviewCallback-这给出了一个字节数组 我可以添加到缓冲区的每一帧.但是,这种方法不提供任何音频数据.

我觉得必须有一种简单的方法来做到这一点,但到目前为止我还没有很多运气. 任何帮助,将不胜感激.

解决方案

JavaCV 提供cvCreateCameraCapture()打开与相机的接口. 此代码演示了如何从相机捕获帧并将其显示在窗口上.

有趣的部分位于while循环中:循环的每次迭代都使用cvQueryFrame()从相机检索单个帧.请注意,此函数返回的数据类型为IplImage,并且该类型负责存储从相机捕获的图像.

您需要做的就是将cvQueryFrame()返回的IplImage存储在循环缓冲区中.

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.

解决方案

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.

这篇关于Android将视频记录到循环缓冲区中并将其存储在RAM中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆