简体   繁体   English

将pcm编码为aac时,OMX.google.aac.encoder在MediaCodec中不起作用

[英]OMX.google.aac.encoder do not work in MediaCodec when encode pcm to aac

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. 我正在Android 4.1上使用MediaCodec将wav文件的pcm轨迹编码为aac,在我的S3上,有两种编码器,即OMX.google.aac.encoder和OMX.SEC.aac.enc,如果调用createEncoderByType,则使用第一个,但它不起作用,无法播放输出(没有声音),如果使用“ OMX.SEC.aac.enc”调用createByCodecName,则它可以工作。 While on my HTC ONE, there is only "OMX.google.aac.encoder", and does not work. 在我的HTC ONE上,只有“ OMX.google.aac.encoder”,无法正常工作。 I think my code has no problem, because it was copied from google, and the second encoder works. 我认为我的代码没有问题,因为它是从Google复制而来的,第二个编码器也可以工作。

BTW, I added adts header to the aac stream. 顺便说一句,我添加了adts标头到aac流。

On my Nexus 5, MediaCodec.createByCodecName() never seems to work when passing names of encoders (as specified by MediaCodecList). 在我的Nexus 5上,传递编码器名称(由MediaCodecList指定)时,MediaCodec.createByCodecName()似乎永远无法正常工作。

The AAC encoders on my Nexus 5 (4.4.4): Nexus 5(4.4.4)上的AAC编码器:

name: OMX.google.aac.encoder types: [audio/mp4a-latm] 名称:OMX.google.aac.encoder类型:[audio / mp4a-latm]

name: AACEncoder types: [audio/mp4a-latm] 名称:AACEncoder类型:[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. 因此,如果这对您不起作用,则可能是在编码器的实现中,而不是在MediaCodec创建中。

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

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