问题
I am encoding pcm track of wav file into aac using MediaCodec on Android 4.1, on my S3, there are two encoders, OMX.google.aac.encoder and OMX.SEC.aac.enc, the first one is used if call createEncoderByType, but it does not work, the output can't be played(has no sound), if call createByCodecName with "OMX.SEC.aac.enc", it works. While on my HTC ONE, there is only "OMX.google.aac.encoder", and does not work. I think my code has no problem, because it was copied from google, and the second encoder works.
BTW, I added adts header to the aac stream.
回答1:
On my Nexus 5, MediaCodec.createByCodecName() never seems to work when passing names of encoders (as specified by MediaCodecList).
The AAC encoders on my Nexus 5 (4.4.4):
name: OMX.google.aac.encoder types: [audio/mp4a-latm]
name: AACEncoder types: [audio/mp4a-latm]
This works however:
MediaCodec.createEncoderByType("audio/mp4a-latm");
Note: curiously, when calling this method the logs reveal:
A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
which is kind of odd.
So if this is not working for you, then it is probably in your implementation of the encoder rather than MediaCodec creation.
来源:https://stackoverflow.com/questions/20768695/omx-google-aac-encoder-do-not-work-in-mediacodec-when-encode-pcm-to-aac