简体   繁体   English

怎么能在电话录音机Android中压缩音频

[英]How Can Compress Audio In Call Recorder Android

I Used This Code Capture Audio In Android Studio But Size Audio Its Big(1min=1MB) How Can Compress Audio Without Quality loss 我在Android Studio中使用此代码捕获音频但大小音频大(1分钟= 1MB)如何在没有质量损失的情况下压缩音频

AudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
AudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
AudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
AudioRecorder.setAudioChannels(1);
AudioRecorder.setAudioEncodingBitRate(44100);
AudioRecorder.setAudioSamplingRate(128000);

You're setting the encoder to AMR_N8. 您正在将编码器设置为AMR_N8。 About 1 MB/sec sounds about right for that encoder. 大约1 MB /秒的声音适合该编码器。 If you want to compress it you can choose another encoding, such as Vorbis. 如果要压缩它,可以选择其他编码,例如Vorbis。

Please note that the different encoders have different purposes. 请注意,不同的编码器有不同的用途。 None of them will compress without quality loss- we're converting analog sound to digital values, there is always quality loss with that. 如果没有质量损失,它们都不会压缩 - 我们将模拟声音转换为数字值,总是存在质量损失。 Different encoders are optimized for different uses. 不同的编码器针对不同用途进行了优化。 AMR is optimized for human voice. AMR针对人声进行了优化。 It filters out frequencies not in vocal range. 它过滤掉不在声音范围内的频率。 That's a quality loss, but it may be one you want (like in a call). 这是一种质量损失,但它可能是你想要的(如在通话中)。 You can't get everything- you're going to have to sacrifice size or quality. 你无法获得一切 - 你将不得不牺牲尺寸或质量。 I suggest you study up on the different encodings found at https://developer.android.com/reference/android/media/MediaRecorder.AudioEncoder.html and figure out what's best for you. 我建议你研究一下https://developer.android.com/reference/android/media/MediaRecorder.AudioEncoder.html上的不同编码,找出最适合你的方法。

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

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