Android 录音文件大小有点大

Android 录音文件大小有点大,android,audio,recording,Android,Audio,Recording,我正在努力解决这个问题,我更改了比特率以减小录制文件的大小,我的应用程序正确地将音频文件发布到服务器,但我想最小化文件大小,这是我的录制代码 private void startRecording() throws IOException { String state = android.os.Environment.getExternalStorageState(); if (!state.equals(android.os.Environment.MEDI

我正在努力解决这个问题,我更改了比特率以减小录制文件的大小,我的应用程序正确地将音频文件发布到服务器,但我想最小化文件大小,这是我的录制代码

 private void startRecording() throws IOException {

        String state = android.os.Environment.getExternalStorageState();
        if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
            throw new IOException("No SD mounted.  It is" + state
                    + ".");

        }

        mRecorder = new MediaRecorder();
        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mRecorder.setAudioSamplingRate(44100);
        mRecorder.setAudioEncodingBitRate(44100);
        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);


        File path = new File(Environment.getExternalStorageDirectory()
                .getPath());

        if (!path.exists() && !path.mkdirs()) {
            throw new IOException("The file directory is invalid.");
        }else{

            try {
                archivo = File.createTempFile("audio", ".3gp", path);
            } catch (IOException e) {
            }

        }

        mRecorder.setOutputFile(archivo.getAbsolutePath());
        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);


        try {
            mRecorder.prepare();
        } catch (IOException e) {
            Log.e(LOG_TAG, "prepare() failed");
        }

        mRecorder.start();


    }
我现在一分钟的录音容量大约是336KB,我想 将其降低到每分钟100-200 kb左右,而不会松动 多质量


有几件事你可以试试

1) 使用AMR(自适应多速率)进行更高的压缩:

recorder.setAudioEncoder(mRecorder.AudioEncoder.AMR_NB);
AMR宽带和AMR窄带是设备用于电话呼叫的编码方法。可能没有你需要的质量

2) 使用单声道1声道:

mRecorder.setAudioChannels (1)

// Sets the number of audio channels for recording. Call this method before 
// prepare().
// Usually it is either 1 (mono) or 2 (stereo). 

质量很差,不是我想要的:(你能加上第(3)项吗)它显示了如何使用8位深度,而不是每个样本16位的典型默认值AudioFormat类允许您设置ENCODING_PCM_8位和ENCODING_PCM_16位。这可以由AudioTrack和AudioRecord使用。这可能不适用于MediaRecorder。此外,每个样本8位在某些设备上可能无法正常工作。我向您提出挑战查找任何编解码器(aac、mp3、flac等)的音频文件,从中可以按要求的比特率(每分钟100-200 kb)呈现音频…要获得合理的音频质量,您需要每秒而不是每分钟的音频质量…这与移动流媒体的纯信息理论无关…每秒比特数越多,意味着音频曲线的锯齿越少,耳朵越容易听到…要么接受比特率的增加,要么接受质量的降低…我建议您尝试一下每个样本的h值为8,而不是每个样本16位的典型默认值,mono channelhi@ScottStensland i更改了值,压缩程序和我的实时速度为335 kbs/分钟,这是很合理的,而且仍然是一个很好的质量。我认为,对于一个主要使用音频作为源的应用程序,我不想在音频上浪费太多TB或gb/月还有另一种方法@ScottStensland