Combine video files with different start times

I have multiple videos with different start times .I would like to combine these two video files into one file so that:

  1. They appear next to each other and
  2. That they are mixed with taking the time stamps of the start times into account.

for example if i have two videos v1 =200 sec and v2 = 100sec I want v1 play the whole time and v1 to show on the screen according to its timestamp.
At the end i want to save the combine video into a local file.

I have just started with open cv. Any help would be appreciated
Thanks a lot

learn how to use ffmpeg, it was made for tasks like that

1 Like

okay I was just trying to find a way to do it using open cv

Hi @Pj1098

Here is a list of tutorials about VideoCapture and VideoWriter.

Recipe:
1- Open both videos with VideoCapture (one VideoCapture for each video)
2- Analyse duration, frame rate, whatever you need
3- Move to the frame where you want to start consuming de video
4- Create a VideoWriter for your output video file

in a loop:
1- Read one frame from each VideoCapture, you will have two Mat (two images)
2- Combine both images into a new one in the way you like it more, don’t change its size in successive frames
3- Write it to the VideoWriter

At the end, close all. The final video will be silent, no sound.

1 Like

I would recommend a video editing program, of the “non-linear” kind. does the job, requires no programming.

you would drag the video clips into a timeline and adjust their positions in time.

video editing programs take care of differing frame rates and all that complicated stuff.

don’t bother trying to get that done with OpenCV. it isn’t made for that. and don’t even think of “seeking” in a video with OpenCV, that’s broken in many cases.

by the way: tagging a thread as opencv in this forum, which is called “OpenCV”, is very pointless.

1 Like