视频录制到字节数组,而无需编写到文件 [英] Record Video To Byte Array Without Writing To File
问题描述
我使用的是谷歌开发者实现自定义摄像机API指南;它使用 MediaRecorder
一>类来创建和管理摄像机的所有设置/操作。
I'm implementing a custom video camera using the Google Developer API Guide; it uses the MediaRecorder
class to create and manage all the settings/operations of the video camera.
保存的事实,它采取的方式太长写入文件到手机(录音之后,这将是大约5分钟前,我甚至能看到下面的文件库的)它的工作,因为它应该。
Save for the fact that it's taking way too long to write the file to the phone (after recording, it'll be about 5 minutes before I even get to see the file under Gallery), it's working as it should.
但我不想要一个文件:我需要的原始字节数组的记录产生之前,它倾倒到一个文件中。
But I don't want a file: I need the raw byte array the recording produces, before it's dumped into a file.
MediaRecorder
甚至允许你这样做吗?我是在正确的方向?
Does MediaRecorder
even allow you to do this? Am I in the right direction?
什么,我需要一个很好的例子是怎样的 PictureCallback
的的 onPictureTaken()
方法给你一个字节数组,其中包含以字节为单位的图片。
A good example of what I need is how the PictureCallback
's onPictureTaken()
method gives you a byte array which contains the picture in bytes.
推荐答案
MediaRecorder
意很简单:告诉它的投入从何而来,给它一个文件写不出来,并让它运行。
MediaRecorder
is intended to be simple: tell it where the inputs come from, give it a file to write to, and let it run.
如果你想要的东西更灵活,你需要使用媒体codeC
。你想并不真正存在,直到18 API(Android 4.3的),设置的功能
If you want something more flexible, you need to use MediaCodec
. The set of features you want doesn't really exist until API 18 (Android 4.3).
Grafika 包括连续拍摄活动,其中记录H.264视频循环缓冲区中记忆,当你点击捕捉将当前帧集合到一个文件中。这是只有视频;如果你想要的音频,你需要处理的分别。
Grafika includes the "Continuous capture" activity, which records H.264 video to a circular buffer in memory, and writes the current set of frames to a file when you hit "Capture". This is video-only; if you want audio, you'd need to deal with that separately.
有关早期版本的Android系统,你可能需要使用第三方库的ffmpeg一样来处理视频编码,这将显著降低帧速率。
For earlier versions of Android you'd need to use a 3rd-party library like ffmpeg to handle the video encoding, which will reduce your frame rate significantly.
这篇关于视频录制到字节数组,而无需编写到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!