I need your help for the below query:

Query:

Is there any way of getting following info of an audio file.

Sample rate, Channel, Bitrate of an audio file.

For extracting bitrate, "MediaMetadataRetriever" API is available (METADATA_KEY_BITRATE).

Please suggest if it can be done using any android API.

I want to extract these using Android API programmactically :

Sampling rate, Quantization, Channel of an input audio file.

Please help on this.

Thanks in advance.

解决方案

This can be done using MeiaExtractor like this:

MediaExtractor mex = new MediaExtractor();

try {

mex.setDataSource(path);// the adresss location of the sound on sdcard.

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

MediaFormat mf = mex.getTrackFormat(0);

int bitRate = mf.getInteger(MediaFormat.KEY_BIT_RATE);

int sampleRate = mf.getInteger(MediaFormat.KEY_SAMPLE_RATE);

int channelCount = mf.getInteger(MediaFormat.KEY_CHANNEL_COUNT);

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐