videoffmpegcentosvideo-encoding

Combine two vides with ffmpeg


I want to combine two mp4 videos to form a single mp4 video using ffmpeg.

what i tried so far is:

ffmpeg -i input1.mp4 -i input2.mp4 output.mp4

But, every time i get the video with video codec of first input and not the other. How can i combine them?


Solution

  • Please read the FFMPEG FAQ for information about joining files.

    Unfortunately, since you're using MP4 files, simple concatenation won't work for you because the MP4 format contains a "header" (although it doesn't necessarily have to be at the beginning of the file) section that describes and contains offsets into the media data. You will need to transcode both files to a format that can be concatenated and then generate an MP4 file from that format (which will generate an appropriate header section).