I need to join a file mp4
(with audio included, recorded from the camera), a song in mp3
(or aac
, or the format that is, I am indifferent in this case). The only condition is that I can not use FFMPEG
.
I found on the internet the MP4Parser that could be similar to what I'm looking for but, there's been no way to make it work:
String f1 = Environment.getExternalStorageDirectory() + "/small.mp4";
String f2 = Environment.getExternalStorageDirectory() + "/musica_1.aac";
MovieCreator.build(f1);
MovieCreator.build(f2);
The error that always gives me is:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.coremedia.iso.boxes.MovieBox.getBoxes(java.lang.Class)' on a null
Surely someone will tell me to check that f1
and f2
are not null: no, they are not, it is more, this problem only arises when I try to join the file I have recorded; if I use a mp4
downloaded from the internet it does not join me but at least it does not give me that error. The error arises as a result of trying to get List<TrackBox> trackBoxes = isoFile.getMovieBox().getBoxes(TrackBox.class);
I need to be able to do the same for the file recorded with the phone.
Next I indicate the configuration to record the video from the phone:
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
if (mNextVideoAbsolutePath == null || mNextVideoAbsolutePath.isEmpty()) {
mNextVideoAbsolutePath = getVideoFilePath(getActivity());
}
mMediaRecorder.setCaptureRate(30);
mMediaRecorder.setOutputFile(Environment.getExternalStorageDirectory()+"/small.mp4");
mMediaRecorder.setVideoEncodingBitRate(10000000);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
Does anyone know a way to join an mp4 with an aac (mp3 or whatever)?