I'm trying to mix a video & audio into one video file using Google M4parser, I created the necessary paths as follows :
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Download";
audioPath = path + "/" + "audio.m4a";
videoNoSoundPath = path + "/" + "video.mp4";
finalVideoPath = path + "/out.mp4";
To make sure all files exist, I put a log :
Log.d("APP:", "SIZE AUDIO: " + FileUtils.getSize(videoNoSoundPath));
Log.d("APP:", "SIZE VIDEO: " + FileUtils.getSize(audioPath));
I'm able to see the size of each file :
1601725413.214 14511-15076/maa.abc D/APP:: SIZE AUDIO: 4.101MB
1601725413.215 14511-15076/maa.abc D/APP:: SIZE VIDEO: 156.150KB
When I run the code below, it's work perfectly fine with all Android version except Android Q :
Mp4ParserAudioMuxer mp4ParserAudioMuxer = new Mp4ParserAudioMuxer();
boolean isOK = mp4ParserAudioMuxer.mux(videoNoSoundPath, audioPath, finalVideoPath);
mSubscriber.notifyData(isOK);
Log.d("APP:", isOK ? " OK " : "NOT OK");
You can find the full mux
method here
Error log :
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.coremedia.iso.boxes.MovieBox.getBoxes(java.lang.Class)' on a null object reference
at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:51)
at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:38)
at maa.abc.utils.mediautils.Mp4ParserAudioMuxer.mux(Mp4ParserAudioMuxer.java:24)
at
maa.abc.ui.activities.EditVideo.lambda$audioVideoMigration$7$EditVideo(EditVideo.java:330)
at maa.abc.ui.activities.-$$Lambda$EditVideo$7NICJDo6IH3OsEAcyQtNXlJY-CI.call(Unknown Source:2)
at com.jyuesong.android.schedule.JObservable$2.run(JObservable.java:52)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
The issue pointed here : video = new MovieCreator().build(videoFile);