Creating a WAV file from raw PCM data using the Android SDK

前端 未结 3 1098
甜味超标
甜味超标 2020-12-03 00:00

I\'m trying to use the AudioRecord class to record a WAV file. The problem is that it only supplies the raw PCM data, and if I write it to a file, there is no header informa

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 00:25

    Check the MediaRecorder.setOutputFormat(), you can set different container formats for your recording; there is MediaRecorder.OutputFormat.MPEG_4 and MediaRecorder.OutputFormat.THREE_GPP; the only allowed format along RAW is setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    Sorry but MP3 is not avail. You really need mp3 for recording? WAV on the opposite of MP3 is a container, not a format; WAV can be any kind of encoding format.

    You are always free to prepend some WAV RIFF header in front of your raw pcm data (as long as you exactly know the format). Check here for how it has to look like: http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html

提交回复
热议问题