Three ways to merge video files with FFmpeg

Source: Internet
Author: User

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.

    1. 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
    2. 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.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.