Android - Concatenate encoded mp3 data and mp3 file data -
i need create audio file made of audio data comes 2 different sources. 1 microphone, recorded audio mp3 file.
i converting read data microphone mp3 using lame library , writing fileoutputstream this:
bytesread = audiorecord.read(buffer, 0, minbuffer); int bytesencoded = androidlame.encode(buffer, buffer, bytesread, mp3buffer); outputstream.write(mp3buffer, 0, bytesencoded);
and have got inputstream (mp3 files) writing same fileoutputstream this:
int buffersize = 1024; byte[] buffer = new byte[buffersize]; int readbytes = 0; while ((readbytes = inputstream.read(buffer)) != -1) { outputstream.write(buffer, 0, readbytes); }
i need alternate these 2 sources , write 1 source @ time. and, want output in mp3 format.
currently, these codes working fine if write data 1 source.
but when i, example, first write data coming file , stop it, , continue writing data coming mic, not working.
i found reason. turns out concatenate mp3 data different sources should have same channels , same sample rate.
the solution decode mp3 files pcm , encode them same configuration using encode data read mic.
Comments
Post a Comment