如何使用android媒体记录器输出基本流?
我想使用 android 中的媒体记录器输出基本视频流,以便使用 live555 进行流式传输。本质上,我想让媒体记录器输出 MPEG-4 视频基本流文件(.m4e
文件)或 H.264 视频基本流文件(.264
文件)。是否可以使用 Android 上的媒体记录器来做到这一点?或者还有其他方法让它发挥作用吗?
I want to output elementary video streams with media recorder in android for the purpose of streaming with live555. In essence, I want to get media recorder to output an MPEG-4 Video Elementary Stream file
(an .m4e
file) or an H.264 Video Elementary Stream file
(an .264
file). Is it possible to do that with media recorder on android? Or is there any other way to get it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 MediaRecorder API 中,我发现您必须在调用 prepare() 之前调用 setOutputFormat(),这限制您选择可用选项之一 - 3GP/MP4。因此,您可以使用自己的解析器来操作来自媒体记录器的转储,这可以为您提供基本流。
From the MediaRecorder APIs I see that you have to call the setOutputFormat() before calling prepare(), this limits you to select one of the available options - 3GP/MP4. Hence you can use your own parser to operate on the dump from the mediarecorder, which can give you elementary streams.
据我了解,答案是,在录制时使用 MediaRecorder 来做到这一点并不容易。录制视频后,您可以使用
ffmpeg
轻松完成此操作。原因是,MediaPlayer
无法录制为基本流。即使我们只录制视频,也会将其放入 3GPP 或 MP4 等容器格式中。现在,对于像ffmpeg
这样的工具来处理这些文件,它们需要 3GPP 或 MP4 标头信息必须存在于录制的文件中。但是,MediaPlayer 仅在完成录制后才会将这些标头写入文件。The answer is, as I understand, that it is not easy to do that with
MediaRecorder
while recording. You may do that without much difficulty, usingffmpeg
once the video is recorded. The reason is that,MediaPlayer
cannot record as elementary streams. Even if we record video only, it will be put in a container format such as 3GPP or MP4. Now, for tools likeffmpeg
to work on these files, they need the 3GPP or MP4 header information must be present on the recorded file. But,MediaPlayer
will write those headers to the file only after it finished recording.