user22139: I have 4 files with same encoding to concatenate


"video1.mp4": duration 3 seconds. Show time from 00:00 to 00.03
"video2.mp4": duration 1 second. Show time from 00:01 to 00.02
"video3.mp4": duration 2 seconds. Show time from 00:01 to 00.03
"video4.mp4": duration 2 seconds. Show time from 00:03 to 00.05


What commands to get the following output?
00:00

00:01 to 00:02

00:03

00:03 to 00:05


user1871: Basic syntax is
ffmpeg -i video1 -i video2 -i video3 -i video4
       -filter_complex "[1]scale=0.40*iw:-1,setpts=PTS-STARTPTS+1/TB[v2];
                        [2]scale=0.40*iw:-1,setpts=PTS-STARTPTS+1/TB[v3];
                        [0][v2]overlay=x=W-w-20:y=H-h-20:eof_action=pass[m2];
                        [m2][v3]overlay=x=W-2*w-40:y=H-h-20:eof_action=pass[m3];
                        [m3][3]concat=n=2:v=1:a=0"   out.mp4

I assume all videos have same resolution and framerate. I've scaled videos 2 and 3 to 40% before overlay and offset their start time to 1 second.

22139: <h2>I have 4 files with same encoding to concatenate</h2>

<blockquote>
  <ul>
  <li>"video1.mp4": duration 3 seconds. Show time from 00:00 to 00.03</li>
  <li>"video2.mp4": duration 1 second. Show time from 00:01 to 00.02</li>
  <li>"video3.mp4": duration 2 seconds. Show time from 00:01 to 00.03</li>
  <li>"video4.mp4": duration 2 seconds. Show time from 00:03 to 00.05</li>
  </ul>
</blockquote>

<h2>What commands to get the following output?</h2>

<p>00:00</p>

<p><a href="https://i.stack.imgur.com/SRRiL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SRRiL.png" alt=""></a></p>

<p>00:01 to 00:02</p>

<p><a href="https://i.stack.imgur.com/nlMnd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nlMnd.png" alt=""></a></p>

<p>00:03</p>

<p><a href="https://i.stack.imgur.com/2y4Wx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2y4Wx.png" alt=""></a></p>

<p>00:03 to 00:05</p>

<p><a href="https://i.stack.imgur.com/bTzxG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bTzxG.png" alt=""></a></p>
 1871: <p>Basic syntax is</p>

<pre><code>ffmpeg -i video1 -i video2 -i video3 -i video4
       -filter_complex "[1]scale=0.40*iw:-1,setpts=PTS-STARTPTS+1/TB[v2];
                        [2]scale=0.40*iw:-1,setpts=PTS-STARTPTS+1/TB[v3];
                        [0][v2]overlay=x=W-w-20:y=H-h-20:eof_action=pass[m2];
                        [m2][v3]overlay=x=W-2*w-40:y=H-h-20:eof_action=pass[m3];
                        [m3][3]concat=n=2:v=1:a=0"   out.mp4
</code></pre>

<p>I assume all videos have same resolution and framerate. I've scaled videos 2 and 3 to 40% before overlay and offset their start time to 1 second.</p>
