Good afternoon, the task was to glue several videos into one (the number of videos is always different (i.e. maybe 1, maybe 2, maybe n)), actually googled this example:
ffmpeg -i new_1.mp4 -i new_2.mp4 -i new_3.mp4 -i new_4.mp4 -filter_complex "nullsrc=size=640x480 [base]; \ [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft]; \ [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright]; \ [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft]; \ [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright]; \ [base][upperleft] overlay=shortest=1 [tmp1]; \ [tmp1][upperright] overlay=shortest=1:x=320 [tmp2]; \ [tmp2] [lowerleft] overlay=shortest=1:y=240 [tmp3]; \ [tmp3][lowerright] overlay=shortest=1:x=320:y=240" -c:v output.mp4
In this example, 4 videos are glued together, but I don’t quite understand, is it possible to write a video position instead of upperright?
example. Let's say that the canvas on which it works will be 1280 by 768 and we have 6 videos (all videos are the same size, but have different lengths, we assume that the size of one video is 1024 by 768). We try to place them in two lines, three videos per line. we get the following dimensions for the video: width: 1280/3 = 426 pixels height: 768/2 = 384, where 2 is the number of lines
Actually questions: 1) Can I set the position of the video wrong?
[0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];
but like this:
[0:v] setpts=PTS-STARTPTS, scale=426x384 [0,384];
[1:v] setpts=PTS-STARTPTS, scale=426x384 [426,384];
or something else? How to make a mesh in ffmpeg?
2) in the case of videos that are different in time, after the shortest video has elapsed, the picture is further slowed down, but the audio track goes, how to solve the given question? do I adjust the short timing video to the longest one? then how is this done? Something like we fill the rest with 4 frames?
thanks for the help.