I didn't expect it to be hard for me to find a solution. But I searched everywhere and yet didn't find a straightforward answer to my question. I have two video files, specifically MP4 files on device storage, and I want to merge the two sequentially and make a single video.
Apparently there are two options: MP4Parser and FFMPEG libraries. I tried both but they depend on other libraries (not mentioned how to add those dependencies) and also I didn't find any clear example of how two video files can be merged using these libraries.
Here is a piece of code I found on Github, but it is still different form what I exactly want:
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("video.h264"));
AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl("audio.aac"));
Movie movie = new Movie();
movie.addTrack(h264Track);
movie.addTrack(aacTrack);
Container mp4file = new DefaultMp4Builder().build(movie);
FileChannel fc = new FileOutputStream(new File("output.mp4")).getChannel();
mp4file.writeContainer(fc);
fc.close();
So I appreciate any help on how I can merge two video files.