Article directory
1. Problem description
There are the following two videos, we want to merge the following videos into one video, (1 in the front and 2 in the back)
2. Solution
2.1
Go to the current folder and execute the command.
Convert all 1.mp4 and 2.mp4 to 1.mpg, 2.mpg, then merge 1.mpg, 2.mpg into output.mpg, and
then convert output.mpg into output.mp4.
ffmpeg -i 1.mp4 -qscale 4 1.mpg
ffmpeg -i 2.mp4 -qscale 4 2.mpg
ffmpeg -i "concat:1.mpg|2.mpg" -c copy output.mpg
ffmpeg -i output.mpg -y -qscale 0 -vcodec libx264 output.mp4
The effect is as follows.
2.2 Merge multiple mp4 files
When there are multiple mp4 files that need to be merged, and the first method is too troublesome, you can use the method introduced below.
Put all mp4 file information into a txt file.
file '1.mp4'
file '2.mp4'
file '3.mp4'
Excuting an order
ffmpeg -f concat -i videolist.txt -c copy out.mp4
It was executed in a flash.