ffmpeg – How to trim multiple videos and position them to specific position using -filter_complex?

How do I mix several videos and have them not overlap each other?
I need to use -filter_complex as I cram many more commands there and seems weird how when I trim video its frames remain and overlap with the other video. I also use tpad to paint the video black where it supposed to be cut but it just makes black images to overlap with other videos instead.

How do I trim and position videos with mix and make sure their frames do not overlap in result?
Here’s the version vithout tpad

./ffmpeg.exe -i input1.mp4 -i input2.mp4 -filter_complex "[0]trim=start=0:end=5[t0];[1]trim=start=5:end=10[t1];[t0][t1]mix=inputs=2" ./output.mp4

It produces such overlapping frames
enter image description here

When adding tpad overlapping changes to mix of frame and black image

./ffmpeg.exe -i input1.mp4 -i input2.mp4 -filter_complex "[0]trim=start=0:end=5[t0];[1]trim=start=5:end=10,setpts=PTS-5/TB,tpad=start_duration=5:start_mode=add:color=black@0x00[t1];[t0][t1]mix=inputs=2" ./output.mp4

enter image description here

The alpha in tpad doesn’t seem to do anything either.

Read more here: Source link