异步使用 MediaCodec 解码和渲染视频文件 [英] Using MediaCodec asynchronously to decode and render a Video File
问题描述
最近开始尝试使用 Android Media Codec 类来渲染来自本机 C++ 应用程序的视频帧.能够使用同步方法[queueInputBuffer 和 deququeInputBuffer] 使用 Android MediaCodec 类成功解码和呈现音频和视频流.
Recently started toying around with the Android Media Codec class to render the video frames from a Native C++ application. Was able to successfully decode and render both audio and video streams using Android MediaCodec class using synchronous approach[queueInputBuffer and deququeInputBuffer].
Android 有一个很好的参考示例,说明如何在 Native C++ Application 中执行此操作.例如:SimplePlayer.cpp
Android has a good reference example of how to do it in Native C++ Application. Ex : SimplePlayer.cpp
现在我已经开始使用回调实现异步方法,并将输入流提供给这些回调中的编解码器[OnInputBufferAvailable/OnOutPutBufferAvailable].
Now i have started with the implementation of asynchronous approach using callbacks and feed the input streams to codec in those callbacks[OnInputBufferAvailable/ OnOutPutBufferAvailable].
我在互联网上四处寻找示例代码,我能找到的只是基于 Java MediaCodec 类的参考.
I was searching around for a sample code on internet and all i can find are the references which are based on Java MediaCodec class.
如果有人有任何示例参考代码或任何链接到基于 C++ 的 MediaCodec 异步使用来呈现视频文件,那就太好了.
If anyone has any sample reference code or any links to the C++ based asynchronous usage of MediaCodec to render a video file, that would be great.
任何关于这方面的指导也很重要.
Any guidance on this would also be great on this.
推荐答案
将 ExtractDecodeEditEncodeMuxTest 示例从同步模式转换为异步模式的示例可在 https://github.com/mstorsjo/android-decodeencodetest.查看导致此操作的所有步骤的提交历史记录.
An example of converting the ExtractDecodeEditEncodeMuxTest example from synchronous mode to asynchronous mode is available at https://github.com/mstorsjo/android-decodeencodetest. See the commit history for all the steps leading up to this.
这不是 C++,也不是用于渲染,但它至少涵盖了一些基本方面.
This isn't C++ and it isn't for rendering, but it covers a few of the essential aspects at least.
这篇关于异步使用 MediaCodec 解码和渲染视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!