使用MediaCodec实现PCM文件格式编码(压缩)成AAC格式

在Android4.1以后google就提供了MediaCodec这个类来为用户提供音视频的编码解码功能(虽然支持的格式不是很多)。

对于MediaCodec类,我们需要大致介绍一下:

官网提供的概述:

In broad terms, a codec processes input data to generate output data. It processes data asynchronously and uses a set of input and output buffers. At a simplistic level, you request (or receive) an empty input buffer, fill it up with data and send it to the codec for processing. The codec uses up the data and transforms it into one of its empty output buffers. Finally, you request (or receive) a filled output buffer, consume its contents and release it back to the codec.

大致的意思是:MediaCodec处理输入数据然后产生输出数据,它异步处理数据,使用了一组输入和输入缓存。你请求到了一个空的输入缓存,将数据填满后,发送给编解码器进行处理。编解码器处理完后,将处理的结果输出到一个空的输出缓存中,我们能请求到这个输出缓存,并将缓存的数据使用。


MediaCode可以处理的数据类型:(1)压缩后的数据(2)原始音频数据(3)原始视频数据

再来了解一下它的状态:


从这个图中我们可以知道:MediaCodec有三种状态(1)Stopped 停止(2)Released释放(3)Executing执行

(1)Stopped停止状态:Error,Uninitialized,configured

(2)

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值