All videos for concatenating FFMPEG must have the appropriate encoding, frame rate, etc., otherwise you will get unexpected results. I think it's hard to do without transcoding if your videos come from different sources. I had to look for a lot of solutions from which I could suggest converting your videos to the same intermediate format, and then run the concat command.
Although this approach works, it does not explain what is going wrong. Jan comment comments on this .
First, check your input files with ffprobe: ffprobe video1.mp4
You will get such results.
video1.mp4:
Stream
video2.mp4:
Stream
Despite the fact that my FPS and other parameters were the same, I got a 58-second video with 3.1 frames / s instead of the expected 8-second / 24-frame video. An important parameter here is the tbn time base , which is 12288 tbn versus 90k tbn . Concatenation does not recode the input video, only the time base from the first input video is used, which spoils all subsequent videos.
Change the temporary base for the first file:
ffmpeg -i video1.mp4 -video_track_timescale 90000 video1_fixed.mp4
Now concatenation gives the correct result:
( echo file 'video2.mp4' & echo file 'video1_fixed.mp4' ) | ffmpeg -y -protocol_whitelist file,pipe -f concat -safe 0 -i pipe: -c copy output.mp4
source share