作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想获取一个音频文件的bitRate,sampleRate,channelCount
我使用代码
@SuppressLint("NewApi")
public void GetSampleRate(String path)
{
MediaExtractor mex = new MediaExtractor();
try {
mex.setDataSource(new File(path).getAbsolutePath());// the adresss location of the sound on sdcard.
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MediaFormat mf = mex.getTrackFormat(0);
bitRate = mf.getInteger(MediaFormat.KEY_BIT_RATE);
sampleRate = mf.getInteger(MediaFormat.KEY_SAMPLE_RATE);
channelCount = mf.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
}
mex.setDataSource(new File(path).getAbsolutePath());
10-13 12:57:52.772: E/WVMExtractor(9554): Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
最佳答案
Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
libwvm.so
版本并将其引入。除了引发异常外,
mex.getTrackFormat(0);
返回空引用,而
mf.getInteger(
使
NPE
崩溃。为避免崩溃,您可以在打印异常的堆栈跟踪后返回。例如。
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
关于java - 尝试获取bitRate,sampleRate,channelCount,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33096709/
我想获取一个音频文件的bitRate,sampleRate,channelCount 我使用代码 @SuppressLint("NewApi") public void GetSampleR
我努力使以下场景按预期工作(代码将在下面提供)。 记录我的麦克风输入并在内存中存储一个 AVAudioPCMBuffer,这是通过 AVAudioPCMBuffer 扩展方法 copy(from
我是一名优秀的程序员,十分优秀!