主要遵循MediaCodec 示例的代码不会生成视频。
与其问一个笼统的问题,不如问一个具体的问题:如果 MediaCodec.releaseOutputBuffer() 成功返回且不产生异常,是否意味着解码工作正常。我正在尝试确定问题是否归因于解码器或表面设置。
MediaCodec.BufferInfo bi = new MediaCodec.BufferInfo();
int iOutputBufferIndex = _mcDecoder.dequeueOutputBuffer(bi, TIMEOUT_USEC);
if (iOutputBufferIndex == MediaCodec.INFO_TRY_AGAIN_LATER) {
// no output available yet
} else if (iOutputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
_bbDecoderOutputBuffers = _mcDecoder.getOutputBuffers();
} else if (iOutputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
MediaFormat newFormat = _mcDecoder.getOutputFormat();
} else if (iOutputBufferIndex < 0) {
//log error;
} else {
//Can the following statement be used to assess the success of the decoding?
_mcDecoder.releaseOutputBuffer(iOutputBufferIndex, true);
}