OP talks about a scaling problem with 256 videos. For that matter I'd recommend automation, for example with Python.
You should generate a command such as the one used at this link but with your videos and the right amount.
We can see that this part is the one that'll change with the number of videos :
Say you have a list of all videos in python (you could do that by hand but i'd recommand using os.listdir
like this)
In the same way you'll have to generate the input for the overlay
filters, this will depend on you output resolution. Let's say it's defined by width
and height
variables. Also, in my example the number of videos of the grid (grid_width
and grid_width
) are set by hand.
Here is a sample of code I don't have the resource or time to test but this should be a good basis for your work :
###list_videos contains the path the the videos
width = 1920
height = 1080
input_videos = ""
input_setpts = "nullsrc=size={}x{} [base];".format(width, height)
input_overlays = "[base][video0] overlay=shortest=1 [tmp0];"
grid_width = 16
grid_height = 16
for index, path_video in enumerate(list_video):
input_videos += " -i " + path_video
input_setpts += "[{}:v] setpts=PTS-STARTPTS, scale={}x{} [video{}];".format(index, width//grid_width, height//grid_height, index)
if index > 0 and index < len(list_video) - 1:
input_overlays += "[tmp{}][video{}] overlay=shortest=1:x={}:y={} [tmp{}];".format(index-1, index, width//grid_width * (index%grid_width), height//grid_height * (index//grid_width), index)
if index == len(list_video) - 1:
input_overlays += "[tmp{}][video{}] overlay=shortest=1:x={}:y={}".format(index-1, index, width//grid_width * (index%grid_width), height//grid_height * (index//grid_width))
complete_command = "ffmpeg" + input_videos + " -filter_complex \"" + input_setpts + input_overlays + "\" -c:v libx264 output.mp4"
print(complete_command)
In the end you can run complete_command
with os.system, information there.