在galaxy s4 4.3上使用android mediacodec编码aac

时间:2015-11-16 03:47:30

标签: android encode mediacodec aac

我使用MediaCodec编码aac流然后mux到mp4,我在大多数设备上测试工作正常,但在Galaxy S4上使用4.3,API级别18,问题出现了,下面是代码:

 if (mHasAudioTrack) {
            mAudioCodec = MediaCodec.createEncoderByType("audio/mp4a-latm");
            MediaFormat audioFormat = MediaFormat.createAudioFormat("audio/mp4a-latm", 44100, 2);
            audioFormat.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectLC);
            audioFormat.setInteger(MediaFormat.KEY_CHANNEL_MASK, AudioFormat.CHANNEL_IN_STEREO);
            audioFormat.setInteger(MediaFormat.KEY_CHANNEL_COUNT, 2);
            audioFormat.setInteger(MediaFormat.KEY_BIT_RATE, 128000);
            try {
                mAudioCodec.configure(audioFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
            } catch (Exception e) {
                Log.e(logTag, "configure audio codec err:"+e.getMessage()+"use no audio");
                mHasAudioTrack = false;
                mAudioCodec.release();
            }
        }

,错误日志为:

> 11-16 11:40:51.006  20858-21098/com.youku.demorecord
> E/TDScreenVideoWriter﹕ Create media codec context. 11-16 11:40:51.126 
> 20858-21594/com.youku.demorecord W/ACodec﹕ [OMX.google.aac.decoder]
> Failed to set standard component role 'audio_encoder.aac'. 11-16
> 11:40:51.126  20858-21594/com.youku.demorecord E/ACodec﹕
> [OMX.google.aac.decoder] configureCodec returning error -2147483648
> 11-16 11:40:51.126  20858-21594/com.youku.demorecord E/MediaCodec﹕
> Codec reported an error. (omx error 0x80001001, internalError
> -2147483648) 11-16 11:40:51.126  20858-21098/com.youku.demorecord E/TDScreenVideoWriter﹕ configure audio codec err:nulluse no audio

任何参数都错了? 有没有人面临同样的问题,可以给我一些提示吗?非常感谢。 顺便说一句:我不想编译第三个aac编码器库使用ndk。

0 个答案:

没有答案