NMNM
NMNM

Reputation: 293

Add audio to video in android

I want to develop an android application which can record a video (mp4), then I have some audio files (mp3) in my resources folder, and I want to add it to the end of the video. So the final effect will be like first the video is played and at the end of video the added audio will be heard. how can I do it?

Upvotes: 15

Views: 14181

Answers (3)

rKrishna
rKrishna

Reputation: 1399

After api version 18 android MediaCodec apis supports to access the low level api. MediaMuxer muxing the elementary streams.

https://developer.android.com/reference/android/media/MediaMuxer.html

Upvotes: 1

Sebastian Annies
Sebastian Annies

Reputation: 2468

Combing to files with different audio codecs is not easily possible. I would do the following:

  • convert the MP3 files to the same format as the video (most likely AAC in an MP4 container)
  • Now you can use mp4parser's AppendExample to append the recorded video with the pre-recorded sound
  • The result will be one MP4 file containing the video first and the sound.

Full disclosure: I am the maintainer of mp4parser.

Upvotes: 8

MBMJ
MBMJ

Reputation: 5431

Make two activity ,one for video,and one for audio.Make the video activity main .Then set waiting time for audio.And call the audio activity using intend.So play the video,after the waiting time end the audio will be played at the end of the video.Set the audio waiting time perfectly.So it will play after the video end

Upvotes: -5

Related Questions