How to concat or merge two or more video files in Android?

The most generic tool you can use is ffmpeg (as noted by @Jeremy above), but using it on the mobile handset will require some work; also it is LGPL licensed and some of its encoders (notably x264) are GPL.

A simpler solution, if both files you want to concatenate are using similar encoding, and are contained in file formats derived from MP4 (3GP is such), is to use a pure-java MP4 parser and concatenate the videos without touching the media stream itself. Have a look at mp4parser, an open-source parser that is pure-java, licensed under Apache license and even has an example for concatenating videos in its wiki.


You can try INDE Media for Mobile, tutorials are here: https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials

It has transcoding\remuxing functionality in MediaComposer class and a possibility to join file\file segments. Since it uses MediaCodec API inside encoding is done on GPU so is very battery friendly and works as fast as possible.

Sample code showing how to enable join or other functionality is on github: https://github.com/INDExOS/media-for-mobile

enter image description hereenter image description hereenter image description here