Mediacodec需要MediaFormat

时间:2013-02-19 13:24:10

标签: android h.264 android-4.2-jelly-bean decoder

我正在尝试使用媒体编解码器解码h264文件。由于Android没有直接支持,我正在配置自己的解码器。为此,我尝试了如下。

codec = MediaCodec.createDecoderByType("video/avc");
format.createVideoFormat("video/avc", /*640*/320, /*480*/240);
try {
    codec.configure(format, null, null,0);
} catch(Exception codec) {
    Log.i(TAG,"codec_configure " +codec.getMessage());
}
//codec.start();
codec.getInputBuffers();
codec.getOutputBuffers();
inputBuffers = codec.getInputBuffers();
outputBuffers = codec.getOutputBuffers();

我在NullPointerException获得format.creatvideoformat()IllegalStateException获得codec.start()

有人可以帮我解决吗?

1 个答案:

答案 0 :(得分:1)

我觉得createVideoFormat可能是

format = MediaFormat::createVideoFormat("video/avc", /*640*/320, /*480*/240);