Reputation: 10789
I'm trying to mix a MP3 audio file into a MP4 video. After hours of searching, I've concluded that I need to convert the MP3 files to an AAC format, which would fit in a MP4 container.
But I can't find any documentation on how to convert the MP3 files into AAC format. So do you have any advice on how I could convert a MP3 audio to an AAC audio ?
Also, I would need to insert several audios at specific times in the final video.
Upvotes: 2
Views: 6500
Reputation: 3850
You can try to use mp4parser which does some muxing to mp4, there are some people (as seen from within github repo "issues" part) who are using this to mux mp3 and mp4.
Another option you've got is to use FFmpeg, either compile your self or use something premade, I've used this. Library it self is a bit bulky, plus you might need some playing around to get FFmpeg commands right in order to get optimum quality and mux speed.
It looks something like this:
try {
FFmpeg ffmpeg = FFmpeg.getInstance(this);
String cmd = "-i " + videoFilePath + " -i " + audioFilePath + " -shortest -threads 0 -preset ultrafast -strict -2 " + outputFilePath
ffmpeg.execute(cmd, mergeListener);
} catch (FFmpegCommandAlreadyRunningException e) {
e.printStackTrace();
}
And a listener:
ExecuteBinaryResponseHandler mergeListener = new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {
//started
}
@Override
public void onFailure(String message) {
//failed
}
@Override
public void onFinish() {
File output = new File(outputFilePath);
//Do whatever with your muxed file
}
};
Upvotes: 4