0

How to merge/mix/overlay multiple videos, with time-shifts?

Example: I'd like to take:

  • 4 seconds of 1.mp4 and it should start at 0'10" in the output video
  • 8 seconds of 2.mp4 and it should start at 0'11" in the output video
  • 16 seconds of 3.mp4 and it should start at 0'12" in the output video

They will be overlaying/overlapping themselves; example: if 1.mp4 is 400x400, 2.mp4 is 200x200, and 3.mp4 is 100x100 pixels, then at 0'12" we will see the 3 videos at the same time, overlapping each other.

ffmpeg -t 4 -i 1.mp4
       -t 8 -i 2.mp4
       -t 16 -i 3.mp4
       -filter_complex [0][1][2]overlay[out]
       -map [out]
       out.mp4 -y

I see there is a overlay t parameter, but how to specify a different starting-timestamp for each video?

It seems we cannot use -itsoffset for multiple sources at the same time: https://trac.ffmpeg.org/ticket/1349

Basj
  • 41,386
  • 99
  • 383
  • 673
  • Search `[ffmpeg] is:answer overlay setpts` – llogan Feb 17 '21 at 18:49
  • Thank you @llogan. I read them carefully, and I have now a working code, but it seems unnecessarily complex, do you think you know how to simplify this code: https://stackoverflow.com/questions/66256414/mixing-various-audio-and-video-sources-into-a-single-video? Thanks in advance. – Basj Feb 18 '21 at 08:53

0 Answers0