سؤال

I am trying to decode a h264 file using media codec. As it is not directly supported by Android, I am configuring my own decoder. 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()

Could anyone help me to fix it?

هل كانت مفيدة؟

المحلول

I feel the createVideoFormat could be

format = MediaFormat::createVideoFormat("video/avc", /*640*/320, /*480*/240);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top