There are three ways to combine video ffmpeg. Most of the domestic only introduced one of them. So I think it's necessary to translate a bit. In fact, in FFmpeg's FAQ document, there are more detailed instructions.
- Merging video files using the CONCAT protocol
The application scenario of this method is: Video container is MPEG-1, MPEG-2 PS or DV can be directly merged. In other words, you can actually merge the video directly with commands such as cat or copy. Many articles describe this approach, but the applicability is not mentioned. This is not a generic approach. Examples of typical commands are:
Ffmpeg-i concat: "Intermediate1.mpg|intermediate2.mpg"-C copy Intermediate_all.mpg
- Merging video files with Concat demuxer
The scenario for this consolidation is when the container format does not support merging of file hierarchies and does not want to (do not require) recoding operations. In this way, the source video also has the same format as the same nature requirements. See here for its detailed syntax. Examples of typical commands are:
Ffmpeg-f concat-i cam01.txt-c Copy Cam01.mp4
Where Cam01.txt is a description file containing the input file.
- To merge video files using the Concat filter (filter):
When any degree of re-encoding is required, the official recommended method is to use the concat filter for merging video files. See here for detailed instructions. Examples of typical commands are:
Ffmpeg-i opening.mkv-i episode.mkv-i ending.mkv-filter_complex ' [0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2 : 2] concat=n=3:v=1:a=2 [v] [A1] [A2] ' -map ' [v] '-map ' [A1] '-map ' [A2] ' output.mkv
The purpose of this order is to merge three bilingual video formats into the final video (output.mkv). The parameter n=3 indicates that the video to be synthesized has three segments, the v=1 shows that the video stream is one, and the a=2 shows that the audio stream is two. A detailed description of the-map parameter can be found in the filtergraph documentation.
Three ways to merge video files with FFmpeg