2016-04-07 49 views
0

我使用媒體記錄器錄製音頻文件 而我想減少輸出文件的大小或質量 如何以低質量降低輸出文件大小?媒體記錄器減少輸出文件大小

這是我的代碼

private MediaRecorder recorder = null; 

int audioformat = Integer.parseInt(prefs.getString(Preferences.PREF_AUDIO_FORMAT, "1")); 
    switch (audioformat) { 
    case MediaRecorder.OutputFormat.THREE_GPP: 
     suffix = ".3gpp"; 
     break; 
    case MediaRecorder.OutputFormat.MPEG_4: 
     suffix = ".mpg"; 
     break; 
    case MediaRecorder.OutputFormat.RAW_AMR: 
     suffix = ".amr"; 
     break; 

    } 

    recorder.setAudioSource(audiosource);  recorder.setOutputFormat(audioformat); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); 
    recorder.setOutputFile(recording.getAbsolutePath()); 
+0

它與採樣率有關:http://stackoverflow.com/questions/16354269/sample-rate-in-android-audio-record-class-and-mediarecord-class –

回答

0

Use setProfile(),選擇一個低質量的​​,如QUALITY_LOW

+0

我試試這個rec​​order.setProfile( CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));但輸出文件大小爲0,0 kb – user5050715

+0

是什麼錯誤? – user5050715