Search code examples
androidaudio-recordingmediarecorder

How can I record audio into existing audio file with append mode?


How can I record audio into existing audio file with append mode, which contains both audio recording in single file.

Example:

I have recorded 1.amr file. Playing time is 00:30 sec, now I have to record another 00:20 sec but file should be same and next recording should append existing 00:30 sec recording. So now playing time will be 00:50 sec.
Is it possible in Java or Android?
Any library is avaliable for this?


Solution

  • You need to record files separately and then can join them together.

    Use RAW AMR format. i.e. set recorder settings to:

    recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    

    Once you have audio files generated in RAW AMR, you can join these files by striping the first 6 byes of file you are appending. Open the audio files in binary mode for the same.