CoolStack
CoolStack

Reputation: 33

Combine multiple videos with specific duration

I am going to concat multiple videos so I can get one video file with FFmpeg.

I've found several ways to implement this but all ways I found can't concat with specific duration of each video.

It means they only concat whole videos.

Exactly, what I wanted is to insert video1 into video2 with specific time. While searching several articles related with this, I checked many articles say "It is impossible with ffmpeg".

So I am trying to split video2 into two videos( like video2-1,video2-2) and concat video1, video2-1, video2-2.

Upvotes: 0

Views: 1103

Answers (1)

Dirk V
Dirk V

Reputation: 1469

what you can do is using trim and atrim in filter complex.

example

ffmpeg -i vid1.mp4 -i vid2.mp4 -filter_complex "[0:v]trim=0:2,setpts=PTS-STARTPTS[v1];[1:v]trim=3:6,setpts=PTS-STARTPTS[v2];[0:a]atrim=0:2,asetpts=PTS-STARTPTS[a1];[1:a]atrim=3:6,asetpts=PTS-STARTPTS[a2];[v1][a1][v2][a2]concat=n=2:v=1:a=1" out.mp4

this will cut vid1 from 0 to 2 and vid2 from 3 tot 6 and combine those together.

Upvotes: 2

Related Questions