mp4parser icon indicating copy to clipboard operation
mp4parser copied to clipboard

Obtain MP4 with two audio files mixed

Open JuGon83 opened this issue 9 years ago • 2 comments

I am wondering if is it possible.

I have two MP4 audio files and one MP4 video file. I need to combine them to reproduce the video and the two sounds at same time (Parallel, Not concatenate), in order to get an only MP4 file.

For example, I have an MP4 audio file with voice, another with music, and another with video. I need that they play all together like a videoclip.

I have been trying to add several tracks to movie with MP4Parser with:

video.addTrack(audioTrack1); video.addTrack(audioTrack2);

But when I play it, I only can hear one of them. Maybe MP4Parser is working correctly and I didn't understand its functionality, for this cause I need a suggest about it.

Is it possible to do this with MP4Parser or I am wrong and it is impossible?

If it is possible, please could you tell me how?

Thank you in advance.

JuGon83 avatar Apr 24 '16 19:04 JuGon83

I'm facing this as well, but I think it is my playback solution only supporting playing back one audio track. Would love to know if there is a good way to merge the audio into one track.

pajama avatar Jun 29 '17 23:06 pajama

i found the solution for mixing twoi audios : val movie = Movie() val rec1 = list[0] val rec2 = list[1] val mov1 = MovieCreator.build(rec1).tracks[0] val mov2 = MovieCreator.build(rec2).tracks[0] //movie.addTrack(mov1) //movie.addTrack(mov2) movie.addTrack(AppendTrack(mov1, mov2)) val builder = DefaultMp4Builder().build(movie) val outX = Environment.getExternalStorageDirectory().absolutePath + "/" + Environment.DIRECTORY_MUSIC + "/outX_${System.currentTimeMillis()}.m4a" val fileChannel = FileOutputStream(outX).channel builder.writeContainer(fileChannel) fileChannel.close()

i am using AppendTrack to append multiple audios

chasfirr avatar Jul 24 '23 12:07 chasfirr