简体   繁体   English

Mediacodec所需的MediaFormat

[英]MediaFormat required for Mediacodec

I am trying to decode a h264 file using media codec. 我正在尝试使用媒体编解码器解码h264文件。 As it is not directly supported by Android, I am configuring my own decoder. 由于Android不直接支持它,因此我正在配置自己的解码器。 For that I've attempted as follow. 为此,我尝试如下。

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();

I am getting NullPointerException at format.creatvideoformat() and also IllegalStateException at codec.start() 我在format.creatvideoformat()处收到NullPointerException ,在codec.start()处也codec.start() IllegalStateException

Could anyone help me to fix it? 谁能帮我修复它?

我觉得createVideoFormat可能是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM