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 has a good reference example of how to do it in Native C++ Application. Ex : SimplePlayer.cpp
Now i have started with the implementation of asynchronous approach using callbacks and feed the input streams to codec in those callbacks[OnInputBufferAvailable/ OnOutPutBufferAvailable].
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.
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.
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.
This isn't C++ and it isn't for rendering, but it covers a few of the essential aspects at least.
来源:https://stackoverflow.com/questions/50880232/using-mediacodec-asynchronously-to-decode-and-render-a-video-file