How to merge two mp3 files into one (combine/join)

前端 未结 2 429
死守一世寂寞
死守一世寂寞 2020-11-30 07:07

Can any tell how to combine/merge two media files into one ?

i found a topics about audioInputStream but now it\'s not supported in and

2条回答
  •  有刺的猬
    2020-11-30 07:43

    Consider two cases for .mp3 files:

    • Files with same sampling frequency and number of channels

    In this case, we can just append the second file to end of first file. This can be achieved using File classes available on Android.

    • Files with different sampling frequency or number of channels.

    In this case, one of the clips has to be re-encoded to ensure both files have same sampling frequency and number of channels. To do this, we would need to decode MP3, get PCM samples,process it to change sampling frequency and then re-encode to MP3. From what I know, android does not have transcode or reencode APIs. One option is to use external library like lame/FFMPEG via JNI for re-encode.

提交回复
热议问题