The improved version of the code (with automatic cropping to the grid) is now built into Reaper under Public Domain license from the 16th of June 2020 with the release of REAPER 6.12c. It is to be found in the Video Processor as the "Combine: Grid of videos" preset! You won't need to copy and paste the code any more!
The extra features are demostrated at:
[ Ссылка ]
Synchronising video files is discused in the introduction. To see the method of setting up the video processor for showing a 2x2 grid of singers go to 2:43 and to automatically show all videos in a grid with automatically assigned column and row numbers watch from 4:05. For forcing the video window to be in landscape see 4:58.
For a fancier version of code (where you have to drag the "Landscape or Portrait" dial to 1) go to: [ Ссылка ]
N.B. Make sure the track with the Video Processor effect is above all the tracks that have video in them in the tracks list. I have used an audio guide track as the top track. If you want to use a video for the initial guide track recording then you need to drag the track with the Video Processor effect to the very top of the tracks list (because otherwise the video guide track will hog the video display).
Cockos REAPER [ Ссылка ] has spectacular possibilities for video considering it is a digital audio workstation (DAW). I have made this video to demonstrate how, at the time of making this video, you can make a landscape grid of any number of portrait video files in REAPER to make a virtual choir video. This is particularly useful for doing remote collaboration videos (which are popular with the COVID-19 outbreak going on at the moment). The number of columns and rows automatically adjust to play all available video tracks below the top track (which is running the Video Processor effect). Videos are not cropped and are ordered left to right, top row first.
If you want a landscape video featuring a grid of landscape videos then have a look at [ Ссылка ] instead. If some tracks have videos that stop or start (causing videos to hop around) you can drag an image file into Reaper and drag the duration of the image item to fill in all the gaps in track. If all tracks are full of either video file items and/or image file items then the allocation of videos on the grid will be stable.
Use the Video Processor effect and select the "Combine: Grid of videos" preset and drag the Landscape/Sq/Portrait dial as required. You won't need to copy and paste the code any more! The exact code for pasting into the Video Processor effect for reproducing this video is:
// grid of portrait videos - automatically draws any number of videos from tracks
x=0;
count_tracks = input_track_count();
aspect = project_w/project_h;
rows = ceil(sqrt(count_tracks)/aspect);
cols = ceil(count_tracks/rows);
rows_alt = rows - 1;
cols_alt = ceil(count_tracks/rows_alt);
min(rows*(aspect^2),cols_alt) == cols_alt ? (cols = cols_alt;rows = rows_alt;);
loop(count_tracks,
gfx_blit(input_track(x), 1 /* preserve aspect */,
(x%cols)*project_w/cols, ((x - (x%cols))/cols)*project_h/rows, // position
project_w/cols,project_h/rows // output width and height
);
x += 1;
);
// End of code
![](https://s2.save4k.ru/pic/u1s4dCGEGv4/maxresdefault.jpg)