Jump to: navigation, search

Difference between revisions of "Autopano Video - Concatenate several mp4"

 
(30 intermediate revisions by 6 users not shown)
Line 1: Line 1:
= FFMPEG method (Concatenation of files with same codecs) =
+
__NOTOC__
*For more information about [[http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files concatenation with ffmpeg ]]
+
There are 2 methods!
+
====Concat demuxer method (It works with Gopro Hero3 black mp4 files)====
+
The concat demuxer was added to ffmpeg 1.1. You can read about it in the [[http://ffmpeg.org/ffmpeg-formats.html#concat documentation]].
+
  
*'''Instructions:'''
+
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<br/>'''See [[Autopano Video - Tools menu]]'''
Create a file "Cam01.txt" with all the (files relative or absolute paths) you want to have concatenated in the following form ( Lines starting with a dash are ignored ):
+
<br/><br/>
  
 +
 +
== 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) ==
 +
 +
* [http://ffmpeg.org/trac/ffmpeg/wiki/ For more information about ffmpeg]
 +
* [http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files 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 [http://ffmpeg.org/ffmpeg-formats.html#concat documentation].
 +
 +
 +
* '''Instructions:'''
 +
 +
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
 
   # this is a comment
 
   file '/path/Cam01/GOPR0009.MP4'
 
   file '/path/Cam01/GOPR0009.MP4'
Line 13: Line 35:
 
   file '/path/Cam01/GP020009.MP4'
 
   file '/path/Cam01/GP020009.MP4'
  
Note that these can be either relative or absolute paths. Then you can encode your files with:
+
 
 +
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
 
  ffmpeg -f concat -i Cam01.txt -c copy Cam01.mp4
  
====Concat protocol method (It works with Gopro Hero3 black mp4 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.
 
  
*'''Instructions:'''
+
=== 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. <br/>
 +
Certain files (mpg and mpeg transport streams, possibly others) can be concatenated. <br/>
 +
This is analogous to using cat on UNIX-like systems or copy on Windows. <br/>
 +
In general, the demuxer is the better option.
 +
 
 +
 
 +
* '''Instructions:'''
 +
 
 
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:
 
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:
  
Line 25: Line 55:
 
  ffmpeg -i GP010009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts GP010009.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 GP020009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts GP020009.ts
  ffmpeg -i "concat:GOPR0009.mp4|GP010009.mp4|GP020009.mp4" -c copy -bsf:a aac_adtstoasc Cam01.mp4
+
  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:
 
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:
Line 32: Line 63:
 
  ffmpeg -i GOPR0009.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp1 2> /dev/null & \
 
  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 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 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
 
  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).
 
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).
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
'''BACK TO:''' [[Documentation]] / [[Autopano Video Documentation]]
 +
 +
[[fr:Autopano Video - Enchainer plusieurs mp4]]
 +
 +
[[Category: Autopano Video - Tutorials]]

Latest revision as of 16:14, 8 June 2016


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)

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.


  • Instructions:

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.


  • Instructions:

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).









BACK TO: Documentation / Autopano Video Documentation