I am trying to replace the audio of an mp4 video. I have a mp4 source file and a .aac audio file. Mp4 file I am recording from native android MediaRecorder following is my code used for recording mp4 video.
Above MediaRecorder object is being used to generate mp4 video file. I downloaded .aac file from some internet source & I don't know its bit-rate, encoding etc.
following code I am using for merging/mixing .aac with mp4.
Movie m = MovieCreator.build(video);
List nuTracks = new ArrayList<>();
for (Track t : m.getTracks()) {
if (!"soun".equals(t.getHandler())) {
nuTracks.add(t);
Log.d(TAG,"found video track");
}
}
Track nuAudio = new AACTrackImpl(new FileDataSourceImpl(audio));
Track crop_track= CropAudio(video,nuAudio);
nuTracks.add(crop_track);
m.setTracks(nuTracks);
Container mp4file = new DefaultMp4Builder().build(m);
FileChannel fc = new FileOutputStream(new File(output)).getChannel();
mp4file.writeContainer(fc);
fc.close();
// sending final output file to player.
output file is not playing in some players and playing without audio in some player. I tried to play output file in ubuntu video player as well but there also it could not work. I am not sure whats wrong I am doing but suspecting that it could be different encoding issue but not sure how to deal with that. Any idea/suggestion will be helpful.
I am trying to replace the audio of an mp4 video. I have a mp4 source file and a .aac audio file. Mp4 file I am recording from native android MediaRecorder following is my code used for recording mp4 video.
Above MediaRecorder object is being used to generate mp4 video file. I downloaded .aac file from some internet source & I don't know its bit-rate, encoding etc. following code I am using for merging/mixing .aac with mp4.
output file is not playing in some players and playing without audio in some player. I tried to play output file in ubuntu video player as well but there also it could not work. I am not sure whats wrong I am doing but suspecting that it could be different encoding issue but not sure how to deal with that. Any idea/suggestion will be helpful.