user6099735
user6099735

Reputation:

AudioRecord file size is a little large

I am struggling with this, I have changed the bitrate to reduce the recording filesize, my app correctly posts audio files to a server, yet I want to minimize filesize, this is my record code

 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();


    }

I am getting like 336 kb for 1 minute recording right now, I want to decrease it to around 100 - 200 kb per minute without loosing too much quality

Upvotes: 2

Views: 1442

Answers (1)

Mark JW
Mark JW

Reputation: 496

A couple of things you can try.

1) use AMR (adaptive multi-rate) for higher compression:

recorder.setAudioEncoder(mRecorder.AudioEncoder.AMR_NB);

AMR Wideband and AMR Narrowband are the encoding methods used by the device for telephone calls. Might not have the quality you require.

2) use mono 1 channel:

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). 

Upvotes: 1

Related Questions