我正在接收带有复用 H.264 视频和 AAC 音频流的 MPEG-TS(MPEG 传输流)数据包。我需要能够在 Android 手机上显示音频和视频。我的假设是我需要:
- MPEG-TS 解复用器
- AAC 解码器
- H.264 解码器
- 同步音频和视频播放
假设我是对的(在 Android 2.x 中) MPEG-TS 解复用器不是操作系统的一部分并且必须移植,AAC 和 H.264 解码器都是 Android 操作系统的一部分,但我不确定它们是否有接口,允许在缓冲区中传递数据以及它们是否允许相互时序同步。在最坏的情况下,这些组件也必须移植到这里。
您能给我一些建议吗?从哪里开始?我正在考虑 FFMPEG 移植。还有其他方法吗?
问候,
斯坦恩
I am receiving the MPEG-TS (MPEG transport stream) packets with the multiplexed H.264 video and AAC audio streams. I need to be able to show the audio and video on the Android phone. My assumption is that I need:
- MPEG-TS de-multiplexer
- AAC decoder
- H.264 decoder
- Synchronize the audio and video playback
Assuming that I am right then (in Android 2.x) MPEG-TS de-multiplexer is not part of the OS and must be ported, both AAC and H.264 decoder are part of the Android OS, but I am not sure if they have interface, which allows passing the data in buffers and if they allow mutual timing synchronization. In the worst case those components must be ported here as well.
Can you give me some advices where to start? I was thinking about the FFMPEG porting. Are there any other ways?
Regards,
STeN
发布评论
评论(4)
Android 4.x有OpenMAX,可以播放H264和AAC的TS。您甚至无需担心音频和视频的同步。
查看 NDK 中的 nativemedia 示例。
如果您想支持以前版本的 Android,那么 ffmpeg 可能是一个不错的选择,但它最多只能为您提供 RGB 或任何其他格式的解码视频帧以及 PCM 解码的音频。然后你必须自己实现渲染器和音频播放。我建议阅读本教程 - http://dranger.com/ffmpeg/。它不是特定于 Android 的,但它会让您了解视频播放的工作原理。
Android 4.x has OpenMAX which can play TS with H264 and AAC. You don't even need to worry about synchronisation of audio and video.
Look at the nativemedia sample in the NDK.
If you want to support previous versions of Android, then ffmpeg might be a good choice, but it the maximum it can give you is just decoded video frames in RGB or any other format and decoded audio in PCM. Then you will have to implement renderer and audio playback yourself. I would recommend reading this tutorial - http://dranger.com/ffmpeg/. It is not android specific but it will give you idea how video play works.
你可以参考github上的android-ffmpeg项目。
https://github.com/guardianproject/android-ffmpeg
You may refer to the android-ffmpeg project on github.
https://github.com/guardianproject/android-ffmpeg
在 Gingerbread ( 2.3 ) 中,实际上 stagefright 框架中有一个 MPEG TS 解析器可供您使用。另外,我相信它与 H264 和 AAC 解码器集成得很好。 MPEG TS 解析器没有在任何地方做广告,但支持却默默地坐在那里。我相信他们已经让它支持 HC 或更高版本中的 Apple HTTP Live 流媒体,但代码也位于 Gingerbread ( 2.3 ) 代码库中。框架稍作修改,就可以播放http直播流(实际上是发送TS包)。我想以上信息会对您有所帮助。
维布杰尔
In Gingerbread ( 2.3 ), actually there is a MPEG TS parser in the stagefright framework that you could use. Also, I believe it is well integrated with H264 and AAC decoders. MPEG TS parser is not advertised anywhere but the support is silently sitting there. I believe they have brought it to support Apple HTTP Live streaming in HC or later version but the code is sitting there in the Gingerbread ( 2.3 ) codebase as well. With a minor modification in the framework, you can playback http live streaming ( which actually sends TS packets). I guess the above information would be helpful for you.
Vibgyor
(免责声明:我个人参与了下面链接的免费开源程序的开发)
ZShaolin 提供了 FFMpeg 的静态版本(库和命令行)http://dyne.org/software/zshaolin 还包含其他媒体转换工具。
它的使用可以方便脚本实验,而无需从头开始编译 FFMpeg。
(DISCLAIMER: I'm personally involved in developing the free and open source program linked below)
A static version of FFMpeg (both library and commandline) is provided by ZShaolin http://dyne.org/software/zshaolin also contains other media conversion tools.
Its use can facilitate scripting experiments without having to compile FFMpeg from scratch.