Autopano Video - Concatenate several mp4
From AVP 2.5 we introduced a new tool which will let you concatenate several video files corresponding to one sequence in one single file
See Autopano Video - Tools menu
MPEG Streamclip method (recommended unless you are familiar with FFMPEG)
- Download and open MPEG Streamclip (http://www.squared5.com/)
- Open several files corresponding to one sequence (GOPR0009.MP4, GP010009.MP4, GP020009.MP4...) in the right order.
- Check that the duration of the sequence is right
- Go to "File -> Save As ..." and save your concatenated file on your computer.
FFMPEG method (Concatenation of files with same codecs)
- For more information about ffmpeg
- For more information about How to concatenate (join, merge) media files
There are 2 methods using FFMPEG:
1) Concat demuxer method (it works with Gopro Hero3 black files)
The concat demuxer was added to ffmpeg 1.1. You can read about it in the documentation.
Create a file "Cam01.txt" with all the you want to have concatenated in the following form ( Lines starting with a dash are ignored ):
# this is a comment file '/path/Cam01/GOPR0009.MP4' file '/path/Cam01/GP010009.MP4' file '/path/Cam01/GP020009.MP4'
Note that these can be either relative or absolute paths. Then you can encode your files with:
ffmpeg -f concat -i Cam01.txt -c copy Cam01.mp4
2) Concat protocol method (it works with Gopro Hero3 black files)
While the demuxer works at the stream level, the concat protocol works at the file level.
Certain files (mpg and mpeg transport streams, possibly others) can be concatenated.
This is analogous to using cat on UNIX-like systems or copy on Windows.
In general, the demuxer is the better option.
If you have MP4 files, these could be losslessly concatenated by first transcoding them to mpeg transport streams. With h.264 video and AAC audio, the following can be used:
ffmpeg -i GOPR0009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts GOPR0009.ts ffmpeg -i GP010009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts GP010009.ts ffmpeg -i GP020009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts GP020009.ts ffmpeg -i "concat:GOPR0009.ts|GP010009.ts|GP020009.ts" -c copy -bsf:a aac_adtstoasc Cam01.mp4
If you're using a system that supports named pipes, you can use those to avoid creating intermediate files - this sends stderr (which ffmpeg sends all the written data to) to /dev/null, to avoid cluttering up the command-line:
mkfifo temp1 temp2 temp3 ffmpeg -i GOPR0009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp1 2> /dev/null & \ ffmpeg -i GP010009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp2 2> /dev/null & \ ffmpeg -i GP020009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp3 2> /dev/null & \ ffmpeg -f mpegts -i "concat:temp1|temp2|temp3" -c copy -bsf:a aac_adtstoasc Cam01.mp4
All MPEG codecs (h.264, MPEG4/divx/xvid, MPEG2; MP2, MP3, AAC) are supported in the mpegts container format, though the commands above would require some alteration (the -bsf bitstream filters will have to be changed).