Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Video Editing/Mangling

Reply
 
Thread Tools Display Modes
Old 04-05-2020, 10:17 AM   #1
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default Code for showing a grid of any number of videos with automatic column and row count

I have made some code for showing a grid of videos while automatically allocating a column and row count (leaving black space where necessary). Here's the code to paste into the Video Processor plugin in an empty track with any number of video tracks below it:

Code:
// grid of videos - automatically draws any number of videos from tracks
x=0;
count_tracks = input_track_count();
cols = ceil(sqrt(count_tracks));
rows = ceil(count_tracks/cols);
loop(cols*rows,
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;
);
There are some more code examples in my feature request post at:
https://forum.cockos.com/showthread.php?t=233798
COVID-19 is currently inspiring lots of people to make videos like this.
jak352 is offline   Reply With Quote
Old 04-05-2020, 03:10 PM   #2
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default Video demo of automatic code for grid of videos

There's a video demo of this in action here:

Last edited by jak352; 04-05-2020 at 03:11 PM. Reason: square brackets instead of paranthesis required
jak352 is offline   Reply With Quote
Old 04-06-2020, 07:02 AM   #3
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,293
Default

Quote:
Originally Posted by jak352 View Post
There's a video demo of this in action here:
Jak352, this is amazing!

If you don't mind, I would put your video plugin into the video presets thread that I've started a while ago. (https://forum.cockos.com/showthread.php?p=2265562)

Many thanks
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is offline   Reply With Quote
Old 04-07-2020, 02:44 AM   #4
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,293
Default

Would it be possible to create different patterns? I mean to combine four video instances to a bigger one while the others stay small all around. Is there a way to handle that like tables in HTML with rows and cols?

Greetings
Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆

Last edited by Eliseat; 04-07-2020 at 02:59 AM.
Eliseat is offline   Reply With Quote
Old 04-07-2020, 06:33 AM   #5
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 2,561
Default

Cool, thanks for sharing, can Reaper render this to a new video, for uploading to youtube*? Automatic adjustment of the grid is elegant.

* Oh you answered already in your video, File, Render, Time selection, output format MPEG-4, render 1 file. So just a normal rendering does it already.
TonE is offline   Reply With Quote
Old 04-07-2020, 12:31 PM   #6
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default

Quote:
Originally Posted by Eliseat View Post
Would it be possible to create different patterns? I mean to combine four video instances to a bigger one while the others stay small all around. Is there a way to handle that like tables in HTML with rows and cols?

Greetings
Eli
(EDIT: The code below such as in post #34 now allows for this.)

My code doesn't allow for that as it stands but you could do it like this:

1. Put the videos you want small into tracks 1,2,3,4,5,8,9,12,13,14,15,16. Put a random image into tracks 6,7,10,11.

2. Make a track above all these and use my code and you'll get a 4x4 grid

3. Make a track above all that and put the video into that that you want big and add a new instance of Video Processor on it and choose the "Overlay: Image Overlay" preset and use the zoom knob in the preset to resize the big video.

Last edited by jak352; 05-12-2020 at 01:15 PM. Reason: Typo
jak352 is offline   Reply With Quote
Old 04-08-2020, 12:08 AM   #7
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,293
Default

Quote:
Originally Posted by jak352 View Post
My code doesn't allow for that as it stands but you could do it like this:

1. Put the videos you want small into tracks 1,2,3,4,5,8,9,12,13,14,15,16. Put a random image into tracks 6,7,10,11.

2. Make a track above all these and use my code and you'll get a 4x4 grid

3. Make a track above all that and put the video into that that you want big and add a new instance of Video Processor on it and choose the "Overlay: Image Overlay" preset and use the zoom knob in the preset to resize the big video.
That's a typical Reaper workaround.

Many thanks
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is offline   Reply With Quote
Old 04-08-2020, 07:43 AM   #8
joffo78
Human being with feelings
 
joffo78's Avatar
 
Join Date: May 2012
Posts: 1,118
Default

Good job i love it !
joffo78 is offline   Reply With Quote
Old 04-08-2020, 01:55 PM   #9
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default Using portrait mode videos for "virtual choir" type look

If you are doing recordings with large numbers of choir members you might want to use portriat mode recordings but still want a landscape export. Force REAPER to use landscape mode by going to File>Project Settings>Video and set "Preferred video size..." to 1920 by 1080 pixels. For a "virtual choir" grid of portrait videos put the video processor in the top track with the following code:

Code:
// 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);
 rows*(aspect^2)>cols_alt ? (cols = cols_alt;rows = rows_alt;);
 loop(cols*rows,
   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;
 );

Last edited by jak352; 04-09-2020 at 04:57 AM. Reason: Improved row and column allocation and forcing landscape settings
jak352 is offline   Reply With Quote
Old 04-09-2020, 10:01 PM   #10
pingosimon
Human being with feelings
 
Join Date: Nov 2018
Posts: 61
Default

Nice! Good to have another option.

Your new portrait has a line "aspect = project_w/project_h"

What happens if we insert that into your old code?
pingosimon is offline   Reply With Quote
Old 04-10-2020, 03:54 AM   #11
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default

Quote:
Originally Posted by pingosimon View Post
Nice! Good to have another option.

Your new portrait has a line "aspect = project_w/project_h"

What happens if we insert that into your old code?
Thanks! In my new code "aspect" is just a variable I created and then used in the code to make sure there are fewer rows and more columns where necessary in the correct ratio for using a landscape result from a number of portrait mode videos. The code then checks whether to round up or down the number of rows according to which gives the largest resulting image sizes.

If you want to have the aspect ratio of the videos squashed or stretched to fit you can change the 1 to 0 just before the /* preserve aspect */ comment.

Here's the virtual choir version of the code in action:

Last edited by jak352; 04-10-2020 at 04:08 AM. Reason: included youtube link to code in aciton
jak352 is offline   Reply With Quote
Old 04-12-2020, 11:23 PM   #12
chema001
Human being with feelings
 
Join Date: Feb 2018
Posts: 20
Default

Quote:
Originally Posted by jak352 View Post
I have made some code for showing a grid of videos while automatically allocating a column and row count (leaving black space where necessary). Here's the code to paste into the Video Processor plugin in an empty track with any number of video tracks below it:

Code:
// grid of videos - automatically draws any number of videos from tracks
x=0;
count_tracks = input_track_count();
cols = ceil(sqrt(count_tracks));
rows = ceil(count_tracks/cols);
loop(cols*rows,
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;
);
There are some more code examples in my feature request post at:
https://forum.cockos.com/showthread.php?t=233798
COVID-19 is currently inspiring lots of people to make videos like this.
Thanks, jak352!!

It's really awesome.

How would you do the next idea? I start with your code, with a group of small videos in a grid, but after a seconds, how could I zoom in one of them and then continue in a full screen mode?

Or just how to zoom out a full screen video and finish in a small one that is a cell of a grid...

I repeat: THANKS!!
chema001 is offline   Reply With Quote
Old 04-15-2020, 12:23 AM   #13
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default

Quote:
Originally Posted by chema001 View Post
Thanks, jak352!!

It's really awesome.

How would you do the next idea? I start with your code, with a group of small videos in a grid, but after a seconds, how could I zoom in one of them and then continue in a full screen mode?

Or just how to zoom out a full screen video and finish in a small one that is a cell of a grid...

I repeat: THANKS!!
Hi, thanks! I think the easiest way to do this is to make a copy of the track that you want to be focussed in on (including its video item) and put that new track at the top of the project. This will then be put over the top of the grid. You can split at the cursor (using the S button) and delete the bits of the item that you don't want to hog the screen. To prevent getting the audio from the new track being doubled you can untick Master Send in the Route area for the new track. You can reposition and zoom the top track too with the grid in the background if you put Video Processor>Overlap: Image Overlay onto the new top track. Does this make sense?
jak352 is offline   Reply With Quote
Old 04-15-2020, 05:12 AM   #14
chema001
Human being with feelings
 
Join Date: Feb 2018
Posts: 20
Default

Quote:
Originally Posted by jak352 View Post
Hi, thanks! I think the easiest way to do this is to make a copy of the track that you want to be focussed in on (including its video item) and put that new track at the top of the project. This will then be put over the top of the grid. You can split at the cursor (using the S button) and delete the bits of the item that you don't want to hog the screen. To prevent getting the audio from the new track being doubled you can untick Master Send in the Route area for the new track. You can reposition and zoom the top track too with the grid in the background if you put Video Processor>Overlap: Image Overlay onto the new top track. Does this make sense?
First of all, thanks for your answer. I must try your idea. But it doesn't sound bad Thanks!
chema001 is offline   Reply With Quote
Old 04-23-2020, 02:17 PM   #15
fallforward
Human being with feelings
 
Join Date: Dec 2011
Posts: 43
Default

This is absolutely fantastic! Thank you!
fallforward is offline   Reply With Quote
Old 04-23-2020, 06:19 PM   #16
echan101
Human being with feelings
 
Join Date: Apr 2020
Posts: 2
Default Video Grid with Subtitles and centered last row

Here's some modifications to the code that allow two things:
  1. Centre the last row of videos (Zoom style).
  2. Adjustable black section at the bottom for lyrics.
Code:
// Grid of videos with Subtitles room - automatically draws any number of videos from tracks

//@param 2:ypos "y position" 1 0 600 150 1

height = project_h - ypos;
// width = project_w * height / (ypos + height);

width = project_w;

gfx_set(0);
gfx_fillrect(0,0,project_w,project_h);
x=0;
count_tracks = input_track_count();
cols = ceil(sqrt(count_tracks));
rows = ceil(count_tracks/cols);
loop(cols*rows,
  xpos = 0;
  lastLineCount = (count_tracks-1) % cols + 1; 
  lastLineOffset = (width - width/cols * lastLineCount) / 2 ;
  x >= (cols*rows - cols)                              // Is it the last line?
    ? xpos = (x%cols)*width/cols + lastLineOffset      // x position last line
    : xpos = (x%cols)*width/cols                       // x position non-last line
    ;
  gfx_blit(
    input_track(x), 
    1,                                   // preserve aspect
    xpos,                                // X position
    ((x - (x%cols))/cols)*(height)/rows, // y position
    width/cols,height/rows               // output width and height
  );
  x += 1;
);
echan101 is offline   Reply With Quote
Old 04-24-2020, 09:32 PM   #17
echan101
Human being with feelings
 
Join Date: Apr 2020
Posts: 2
Default Grid Style Centered with borders

A minor edit to allow black borders around each video, so it looks more Zoom style and neater. Also last line centered.

Code:
// Grid of videos - automatically draws any number of videos from tracks with grid

//@param 3:border "Grid Borders" 1 0 20 10 1


gfx_set(0);
gfx_fillrect(0,0,project_w,project_h);
x=0;
count_tracks = input_track_count();
cols = ceil(sqrt(count_tracks));
rows = ceil(count_tracks/cols);
height = project_h - border;
width = project_w - border;
vHeight = height / cols - border;  // Video height
vWidth = width / cols - border;    // Video Width

loop(cols*rows,
  xpos = 0;
  row = ceil((x+1) / cols); // Column position
  col = x % cols;           // Row position
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  lastLineOffset = (width - width/cols * lastLineCount) / 2 ;
  x >= (cols*rows - cols)                              // Is it the last line?
    ? xpos = col*vwidth + lastLineOffset +border*col     // x position last line
    : xpos = col*vwidth + border*col       // x position non-last line
    ;
  gfx_blit(
    input_track(count_tracks - x - 1), 
    0,                                   // don't preserve aspect (low distortion for horiz images)
    border + xpos,                                  // X position
    border + vheight*(row-1) + border*(row-1) + ypos, // Y position
    vwidth,vheight               // output width and height
  );
  x += 1;
);
echan101 is offline   Reply With Quote
Old 04-25-2020, 10:14 AM   #18
fallforward
Human being with feelings
 
Join Date: Dec 2011
Posts: 43
Default

Thank you so much for these. Question where in the code would I enter a value to end the track count so that I could add a background to the video mix?

Also, do you have a paypal I can donate to? You have saved me so much time!
fallforward is offline   Reply With Quote
Old 04-25-2020, 02:15 PM   #19
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default grid with background

Nice work @echan101, thanks! Here's an improved version preserving the aspect ratio for larger borders and using the top track (the one with the video processor in it) as a source for background image/video. Hey, if anyone wants to PayPal me at jonathan@kempstrings.com I won't object!
Code:
// Grid of videos - automatically draws any number of videos from tracks with grid

//@param 3:border "Grid Borders" 1 0 100 50 1


gfx_set(0);
gfx_fillrect(0,0,project_w,project_h);
x=0;
count_tracks = input_track_count();
cols = ceil(sqrt(count_tracks));
rows = ceil(count_tracks/cols);
aspect = project_w/project_h;
height = project_h - border;
width = project_w - border*aspect;
vHeight = height / cols - border;  // Video height
vWidth = width / cols - border*aspect;    // Video Width
gfx_blit(0); //Show current track image or video as background
loop(count_tracks,
  xpos = 0;
  row = ceil((x+1) / cols); // Column position
  col = x % cols;           // Row position
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  lastLineOffset = (width - width/cols * lastLineCount) / 2 ;
  x >= (cols*rows - cols)                              // Is it the last line?
    ? xpos = col*vwidth + lastLineOffset +border*aspect*col     // x position last line
    : xpos = col*vwidth + border*aspect*col       // x position non-last line
    ;
  gfx_blit(
    input_track(count_tracks - x - 1), 
    0,                                   // don't preserve aspect (low distortion for horiz images)
    border*aspect + xpos,                                  // X position
    border + vheight*(row-1) + border*(row-1) + ypos, // Y position
    vwidth,vheight               // output width and height
  );
  x += 1;
);

Last edited by jak352; 04-26-2020 at 04:42 AM. Reason: "Grid Borders" dial is smoother with 1 0 100 50 1
jak352 is offline   Reply With Quote
Old 04-26-2020, 10:14 AM   #20
fallforward
Human being with feelings
 
Join Date: Dec 2011
Posts: 43
Default

Quote:
Originally Posted by jak352 View Post
Nice work @echan101, thanks! Here's an improved version preserving the aspect ratio for larger borders and using the top track (the one with the video processor in it) as a source for background image/video. Hey, if anyone wants to PayPal me at jonathan@kempstrings.com I won't object!
Code:
// Grid of videos - automatically draws any number of videos from tracks with grid

//@param 3:border "Grid Borders" 1 0 100 50 1


gfx_set(0);
gfx_fillrect(0,0,project_w,project_h);
x=0;
count_tracks = input_track_count();
cols = ceil(sqrt(count_tracks));
rows = ceil(count_tracks/cols);
aspect = project_w/project_h;
height = project_h - border;
width = project_w - border*aspect;
vHeight = height / cols - border;  // Video height
vWidth = width / cols - border*aspect;    // Video Width
gfx_blit(0); //Show current track image or video as background
loop(count_tracks,
  xpos = 0;
  row = ceil((x+1) / cols); // Column position
  col = x % cols;           // Row position
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  lastLineOffset = (width - width/cols * lastLineCount) / 2 ;
  x >= (cols*rows - cols)                              // Is it the last line?
    ? xpos = col*vwidth + lastLineOffset +border*aspect*col     // x position last line
    : xpos = col*vwidth + border*aspect*col       // x position non-last line
    ;
  gfx_blit(
    input_track(count_tracks - x - 1), 
    0,                                   // don't preserve aspect (low distortion for horiz images)
    border*aspect + xpos,                                  // X position
    border + vheight*(row-1) + border*(row-1) + ypos, // Y position
    vwidth,vheight               // output width and height
  );
  x += 1;
);
Thank you so much for your efforts. It looks like it is using the top video as the background so the video is doubled, essentially. I was hoping to be able to use a different video as an abstract, fullscreen, background without having it included in the smaller tiled videos. Is that possible?
fallforward is offline   Reply With Quote
Old 04-26-2020, 12:46 PM   #21
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Smile

Quote:
Originally Posted by fallforward View Post
Thank you so much for these. Question where in the code would I enter a value to end the track count so that I could add a background to the video mix?

Also, do you have a paypal I can donate to? You have saved me so much time!
Quote:
Originally Posted by fallforward View Post
Thank you so much for your efforts. It looks like it is using the top video as the background so the video is doubled, essentially. I was hoping to be able to use a different video as an abstract, fullscreen, background without having it included in the smaller tiled videos. Is that possible?
Thanks so much for your appretiation! The way it is working for me is that track 1 in the project has both the Video Processor track running that code and the background video or image (and is put into the video window by the command gfx_blit(0) as it happens).

The videos that make up the grid go in tracks 2, 3, 4 and so on as usual (and are loaded using gfx_blit(input_track(count_tracks - x - 1)...) in the code) with the last one loaded being from track 2 in the project. Actually, you can make the order swap by replacing input_track(count_tracks - x - 1) with input_track(x) which makes more sense to me as then track 2 gives the top left video in the grid.

The long and the short of it is that I think maybe you haven't put a video or image into track 1 (which is the track with the video processor in it) and therefore it is showing track 2 as the background for that reason. Does this help?

Last edited by jak352; 04-26-2020 at 01:10 PM.
jak352 is offline   Reply With Quote
Old 04-26-2020, 04:15 PM   #22
fallforward
Human being with feelings
 
Join Date: Dec 2011
Posts: 43
Default

Quote:
Originally Posted by jak352 View Post
Thanks so much for your appretiation! The way it is working for me is that track 1 in the project has both the Video Processor track running that code and the background video or image (and is put into the video window by the command gfx_blit(0) as it happens).

The videos that make up the grid go in tracks 2, 3, 4 and so on as usual (and are loaded using gfx_blit(input_track(count_tracks - x - 1)...) in the code) with the last one loaded being from track 2 in the project. Actually, you can make the order swap by replacing input_track(count_tracks - x - 1) with input_track(x) which makes more sense to me as then track 2 gives the top left video in the grid.

The long and the short of it is that I think maybe you haven't put a video or image into track 1 (which is the track with the video processor in it) and therefore it is showing track 2 as the background for that reason. Does this help?
You're more than welcome. Thank you! I've been compiling videos from my praise team and you've saved me so much time and made me look like a genius, too!

I got it working. It was as you suspected. I hadn't inserted a video on to the top track yet.

Thanks again!
fallforward is offline   Reply With Quote
Old 04-27-2020, 03:16 AM   #23
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,202
Default

Jonathan or echan,
super work as I already mentioned.
Is there a reason why the first video is being displayed twice (one after another) plus the big one (this one I understand)?

Some muted tracks from above cause that, but do not get the reason why so.
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.

Last edited by urednik; 04-27-2020 at 05:42 AM.
urednik is offline   Reply With Quote
Old 04-27-2020, 10:40 AM   #24
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default

Quote:
Originally Posted by urednik View Post
Jonathan or echan,
super work as I already mentioned.
Is there a reason why the first video is being displayed twice (one after another) plus the big one (this one I understand)?

Some muted tracks from above cause that, but do not get the reason why so.
Sorry, I'm not sure as the first video isn't being displayed twice for me. Is the Video processor running in track 1 (recommended)? Is the background video in track 1 (recommended)? In which track is the video that appears twice?
jak352 is offline   Reply With Quote
Old 04-27-2020, 02:49 PM   #25
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,202
Default

Ok, thanks, I had it on master FX ... Now it works, thanks!
Is there possible to order videos rather in other way? 1st track first in grid? (now it is last)

BTW this was possible with your code

https://www.youtube.com/watch?v=gOx5DkDkceU
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.

Last edited by urednik; 04-27-2020 at 02:56 PM.
urednik is offline   Reply With Quote
Old 04-28-2020, 05:03 AM   #26
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default

Quote:
Originally Posted by urednik View Post
Ok, thanks, I had it on master FX ... Now it works, thanks!
Is there possible to order videos rather in other way? 1st track first in grid? (now it is last)

BTW this was possible with your code

https://www.youtube.com/watch?v=gOx5DkDkceU
Wow! Great work! You can make the order swap by replacing input_track(count_tracks - x - 1) with input_track(x) as discussed in post #21.
jak352 is offline   Reply With Quote
Old 04-28-2020, 10:10 PM   #27
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 494
Default

Here's a helper I made for my wife who is assembling a grid of videos... Unfortunately some are portrait some are landscape, and all need to be panned and zoomed to match scale, and besides there are 15 and she wanted 3 rows of 5, so the auto choir video didn't work.

To make that job simpler, I created this grid framer, and it occurs to me it will also make these auto-generated choir videos look better. It just creates a set of frames, any number of rows or columns with a selectable frame size. She put it on top of all her other videos, and it meams the edges don't have to be pixel perfect. Also, I think these kinds of videos look better with frames. If you set width and height to 1, and left and top to zero it fills the whole window. But you can change its size and position, so you could put 2 rows of 2 on the left half, and 3 rows of 2 on the right. Hope it's useful to someone....

Cheers!

Code:
//Moon Grid Frame
// 'name' [defval minval maxval centval step]

//@param 1:percent_y 'Top' 0.0
//@param 2:percent_x 'Left' 0.0 
//@param 3:percent_h 'Height'  1 0 1 .5 0.01
//@param 4:percent_w 'Width'  1 0 1 .5 0.01
//@param 6:fine_y 'Top-fine' 0 -1 1 0 .01
//@param 7:fine_x 'Left-fine' 0 -1 1 0 .01
//@param 8:fine_h 'Height-fine'  0 -1 1 0 .01
//@param 9:fine_w 'Width-fine'  0 -1 1 0 .01

//@param11:rows 'Rows' 1 1 9 5 1
//@param12:cols 'Columns' 1 1 9 5 1
//@param13:border  'Border' 10 0 50 10 2

//@param15:R 'Red' 1 0 1 0.5 0.1
//@param16:G 'Green' 1 0 1 0.5 0.1
//@param17:B 'Blue' 1 0 1 0.5 0.1

input = 0;
!project_wh_valid && input_info(input,w,h) ? ( project_w=w; project_h=h; );

fine = .05;

dest_x = (percent_x + (fine * fine_x)) * project_w;
dest_y = (percent_y + (fine * fine_y)) * project_h;
dest_w = (percent_w + (fine * fine_w)) * project_w;
dest_h = (percent_h + (fine * fine_h)) * project_h;


input = 0;
gfx_blit(input,1);
gfx_set(R,G,B,1);

//verticals
offset_H = ((dest_w - border) / cols) + dest_x;
col = 0;
loop(cols + 1,
        left = col * offset_H;
        top = dest_y;
        width = border;
        height = dest_h;
        gfx_fillrect(left,top,width,height);
        col = col + 1;
      );
      
//horizontals
offset_V = ((dest_h - border) / rows) + dest_y;
row = 0;
loop(rows + 1,
        left = dest_x;
        top = row * offset_V;
        width = dest_w;
        height = border;
        gfx_fillrect(left,top,width,height);
        row = row + 1;
      );
__________________
eric moon
Very Stable Genius
https://gogolab.com/

Last edited by woodslanding; 04-28-2020 at 10:17 PM.
woodslanding is offline   Reply With Quote
Old 04-28-2020, 11:29 PM   #28
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 5,934
Default

I've got my own code going for this as well.

results from an evening of hacking


https://youtu.be/ASNSDOfUJzU


https://youtu.be/Dz6RxhMtkcY

have to merge my changes into the portrait version still but I'm really happy with these results
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds is offline   Reply With Quote
Old 05-03-2020, 12:56 PM   #29
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default

Here's a version that allows for a larger video within the grid. With "Lead Video Width" set to 2 then the lead video (which can be chosen using "Lead Video Track" dial) will be twice as wide/tall and placed centrally. If it's set to 3 the lead video will be three times as tall/wide and so on. Everything else fits around it. You can also drag the y position of the whole thing using "Y Offset". Border size is set with "Grid Borders". Setting "Preserve Aspect" to 0 means videos/images will be stretched to fit the grid which is unecessary if everything is the same aspect aspect ratio but can be helpful to get rid of any black spaces.

Just place this code in the Video Processor in track 1. Put the videos you want in the grid in tracks 2 onwards. If you want a background image or background video (visible for non-zero Grid Borders values) then put that in track 1. Images count as if they are videos and image items can be resized to fill space (to ensure tracks don't hop around if you don't want them to for instance). The default size/shape of the export video is set by the video or image in track 1 (or track 2 if there's no background image/video in track 1). If you get low quality or output of the wrong size I recommend going to File>Project Settings>Video and setting the preserved video size to what you want (such as 1920 x 1080) and you might find it helps to tick "Always resize video sources..." and "Always resize video output...". It possible to use automation on the parameters if you want to get fancy. Enjoy!

Code:
// Grid of videos - automatically draws any number of videos from tracks with grid 

//@param 1:boss "Lead Video Track" 2 2 10 6 1
//@param 2:Nbig "Lead Video Width" 2 1 9 5 1
//@param 3:yposratio "Y Offset" 0 0 1 0.5 0.01
//@param 4:border "Grid Borders" 5 0 100 50 1
//@param 5:presasp "Preserve Aspect" 1 0 1 0.5 1

boss = boss - 1; // boss is now relative to video processor track 
Ntracks = input_track_count(); // Number of video files
boss>Ntracks ? boss = Ntracks; // If the lead video track set is greater than Ntracks use last
gfx_set(0);
gfx_fillrect(0,0,project_w,project_h);
x=0;
Ntracks > 0 // If there are video tracks then get nonzero number of grid locations
?
count_tracks = Ntracks + Nbig^2 - 1 // Number of grid locations filled
: //else no grid
count_tracks = 0  
;
cols = ceil(sqrt(count_tracks));
rows = ceil(count_tracks/cols);
aspect = project_w/project_h;
height = project_h - border;
width = project_w - border*aspect;
vHeight = height / cols - border;  // Video height
vWidth = width / cols - border*aspect;    // Video Width
top_left_rows = floor((cols - Nbig)/2); // Number of columns (and rows) before big central video
gfx_blit(0); // Show current track image or video as background
bosscount = 0; // Counter for taking into account grid positions for boss video 
loop(count_tracks,
  xpos = 0;
  ypos = yposratio*project_h;
  row = floor(x/cols); // Column position (starts at 0)
  col = x % cols;           // Row position (starts at 0)
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  lastLineOffset = (width - width/cols * lastLineCount) / 2 ;
  x >= (cols*rows - cols)                              // Is it the last line?
    ? xpos = col*vwidth + lastLineOffset +border*aspect*col     // x position last line
    : xpos = col*vwidth + border*aspect*col       // x position non-last line
    ;
 ((row>top_left_rows-1)&(col>top_left_rows-1)&(row<top_left_rows+Nbig)&(col<top_left_rows+Nbig))
    ? // if the grid number corresponds to being part of the big video
    (
    bosscount == 0 // if its the first of the big video then plot it
    ?
    (
      gfx_blit(
        input_track(boss-1),
        presasp,                                   // preserve aspect ratio
        border*aspect + xpos,                                  // X position
        border + vheight*(row) + border*(row) + ypos, // Y position
        Nbig*vwidth+(Nbig-1)*aspect*border,Nbig*vheight+(Nbig-1)*border               // output width and height
      );
    );
      bosscount = bosscount + 1; // increment counter
    )
    : // else if the grid number is not part of the big video
    x-bosscount+1 < Ntracks // if this video number exists
    ?
    (vidnum = x-bosscount+1;
      vidnum < boss ? vidnum = vidnum-1;
    gfx_blit(
      input_track(vidnum), 
      presasp,                                   // preserve aspect ratio
      border*aspect + xpos,                                  // X position
      border + vheight*(row) + border*(row) + ypos, // Y position
      vwidth,vheight               // output width and height
    );
    );
  x += 1;
);

Last edited by jak352; 05-04-2020 at 01:24 AM. Reason: preserve aspect ratio is now optional
jak352 is offline   Reply With Quote
Old 05-08-2020, 05:14 AM   #30
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default Automatic code for grid of videos with large central video portrait or landscape

Here's revised code where you can choose to optimise for landscape or portrait source videos using a dial (assuming landscape output)! It can now allow you to specify a background colour too. As before it allows for a larger video within the grid. With "Lead Video Width" set to 2 then the lead video (which can be chosen using "Lead Video Track" dial) will be twice as wide/tall and placed centrally and so on. Any number of videos then fit around it. You can also drag the y position of the whole thing using "Y Offset". Border size is set with "Grid Borders". Setting "Preserve Aspect" to 0 means videos/images will be stretched to fit the grid which can be helpful to get rid of any black spaces.

Just place this code in the Video Processor in track 1. Put the videos you want in the grid in tracks 2 onwards. If you want a background image or background video (visible for non-zero Grid Borders values) then put an image or video in track 1 and set Background Color/Video to 1. Leave Background Color/Video on 0 if you want to specify a backround color using the RGB knobs instead. Images count as if they are videos and image items can be resized to fill space (to ensure tracks don't hop around if you don't want them to for instance). The default size/shape of the export video is set by the video or image in track 1 (or track 2 if there's no background image/video in track 1). If you get low quality or output of the wrong size I recommend going to File>Project Settings>Video and setting the preserved video size to what you want (such as 1920 x 1080) and you might find it helps to tick "Always resize video sources..." and "Always resize video output...". It possible to use automation on the parameters if you want to get fancy. Enjoy!

Code:
// Grid of videos - automatically draws any number of videos from tracks with grid 

//@param 1:boss "Lead Video Track" 2 2 10 6 1
//@param 2:Nbig "Lead Video Width" 1 1 9 5 1
//@param 3:yposratio "Y Offset" 0 0 1 0.5 0.01
//@param 4:border "Grid Borders" 5 0 100 50 1
//@param 5:presasp "Preserve Aspect" 0 0 1 0.5 1
//@param 6:portrait "Landscape or Portrait" 0 0 1 0.5 1
//@param 7:background "Backdrop Color/Video" 0 0 1 0.5 1
//@param 8:R "Backdrop Red" 0 0 1 0.5 0.01
//@param 9:G "Backdrop Green" 0 0 1 0.5 0.01
//@param 10:B "Backdrop Blue" 0 0 1 0.5 0.01

boss = boss - 1; // boss is now relative to video processor track 
Ntracks = input_track_count(); // Number of video files
boss>Ntracks ? boss = Ntracks; // If the lead video track set is greater than Ntracks use last
gfx_set(0);
gfx_fillrect(0,0,project_w,project_h);
x=0;
Ntracks > 0 // If there are video tracks then get nonzero number of grid locations
?
count_tracks = Ntracks + Nbig^2 - 1 // Number of grid locations filled
: //else no grid
count_tracks = 0  
;
aspect = project_w/project_h;
portrait == 0 
?// if landscape source videos
(
 border_h = border;
 border_w = border*aspect;
 height = project_h - border_h;
 width = project_w - border_w;
 cols = ceil(sqrt(count_tracks));
 rows = ceil(count_tracks/cols);
 vHeight = height / cols - border_h;  // Video height including half border*aspect each side
 vWidth = width / cols - border_w;    // Video Width including half border*aspect each side
)
: // else we assume portrait source videos need to be fitted into landscape output
(
 border_h = border*aspect;
 border_w = border;
 height = project_h - border_h;
 width = project_w - border_w;
 rows = ceil((sqrt(count_tracks))/aspect);
 cols = ceil(count_tracks/rows);
 rows_alt = rows - 1;
 cols_alt = ceil(count_tracks/rows_alt);
 rows*(aspect^2)>cols_alt ? (cols = cols_alt;rows = rows_alt;); // if reducing rows by one is more efficient 
 rows<Nbig ? (rows = Nbig; cols = ceil(count_tracks/rows);); // if number of rows is less than Nbig
 vWidth = width / cols - border_w;    // Video Width
 vHeight = height / rows - border_h;  // Video Height
 aspect < (vHeight/vWidth) // if fitting to width and not tall enough
  ?      
  (xoffset = 0;
   vHeight = vWidth*aspect;)  // Replace video Height
  : // else fitting to height and not wide enough
   (vWidth = vHeight / aspect;  // Replace video Width
   xoffset = (project_w - (cols*vWidth + (cols+1)*border_w))/2;)   
 );
Nbig>1 ? // if one of the videos is chosen to be big
(
left_cols = floor((cols - Nbig)/2); // Number of columns before big central video
top_rows = floor((rows - Nbig)/2); // Number of rows before big central video
)
:
(
left_cols = 0;
top_rows = 0;
);
background == 1 
? 
 gfx_blit(0) // Show current track image or video as background
:
(
 gfx_set(R,G,B,1);
 gfx_fillrect(0,0,project_w,project_h); // Show color as background
);
bosscount = 0; // Counter for taking into account grid positions for boss video 
ypos = yposratio*project_h;
  loop(count_tracks,
  row = floor(x/cols); // Column position (starts at 0)
  col = x % cols;           // Row position (starts at 0)
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  //lastLineOffset = (width - width/cols * lastLineCount) / 2 ;
  lastLineOffset = (project_w - (lastLineCount*vWidth + (lastLineCount+1)*border_w))/2;
  ((x >= (cols*rows - cols))&(bosscount == Nbig^2))                             // Is it the last line?
    ? xpos = col*vwidth + lastLineOffset + border_w*col     // x position last line
    : xpos = col*vwidth + border_w*col + xoffset       // x position non-last line
    ;
 ((row>top_rows-1)&(col>left_cols-1)&(row<top_rows+Nbig)&(col<left_cols+Nbig))
    ? // if the grid number corresponds to being part of the big video
    (
    bosscount == 0 // if its the first of the big video then plot it
    ?
    (
      gfx_blit(
        input_track(boss-1),
        presasp,                                   // preserve aspect ratio
        border_w + xpos,                                  // X position
        border_h + vheight*(row) + border_h*(row) + ypos, // Y position
        Nbig*vwidth+(Nbig-1)*border_w,Nbig*vheight+(Nbig-1)*border_h // output width and height
      );
    );
      bosscount = bosscount + 1; // increment counter
    )
    : // else if the grid number is not part of the big video
    x-bosscount+1 < Ntracks // if this video number exists
    ?
    (vidnum = x-bosscount+1;
      vidnum < boss ? vidnum = vidnum-1;
    gfx_blit(
      input_track(vidnum), 
      presasp,                                   // preserve aspect ratio
      border_w + xpos,                                  // X position
      border_h + vheight*(row) + border_h*(row) + ypos, // Y position
      vwidth,vheight               // output width and height
    );
    );
  x += 1;
);

Last edited by jak352; 05-10-2020 at 04:08 AM. Reason: Now allows for background color. Default Lead Video Width is now set to 1
jak352 is offline   Reply With Quote
Old 05-08-2020, 01:12 PM   #31
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 5,934
Default

I was having some serious issues writing new features into the portrait mode preset originally posted. Thanks for this new preset
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds is offline   Reply With Quote
Old 05-08-2020, 03:06 PM   #32
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Smile

Quote:
Originally Posted by EpicSounds View Post
I was having some serious issues writing new features into the portrait mode preset originally posted. Thanks for this new preset
You're welcome. It's a right mental workout this stuff!
jak352 is offline   Reply With Quote
Old 05-10-2020, 06:41 AM   #33
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default Revised code with option to allow for a big gap in the grid to reveal background

Here's more revised code. If you want a large gap in the grid to allow a big bit of background video/image to be revealled then make Lead Track equal to 1 and switch Backdrop Color/Video to 1 and increase Lead Video Width to taste. This will allow the video on Track 2 to display in the backround instead of being resized within the grid (as long as you leave Track 1 empty of video/images).

You can choose to optimise for landscape or portrait source videos using a dial (assuming landscape output)! It can now allow you to specify a background colour too. As before it allows for a larger video within the grid. With "Lead Video Width" set to 2 then the lead video (which can be chosen using "Lead Video Track" dial) will be twice as wide/tall and placed centrally and so on. Any number of videos then fit around it. You can also drag the y position of the whole thing using "Y Offset". Border size is set with "Grid Borders". Setting "Preserve Aspect" to 0 means videos/images will be stretched to fit the grid which can be helpful to get rid of any black spaces.

Just place this code in the Video Processor in track 1. Put the videos you want in the grid in tracks 2 onwards. If you want a background image or background video (visible for non-zero Grid Borders values) while still preserving the video on track 2 within the grid then put an image or video in track 1 and set Background Color/Video to 1. Leave Background Color/Video on 0 if you want to specify a backround color using the RGB knobs instead. Images count as if they are videos and image items can be resized to fill space (to ensure tracks don't hop around if you don't want them to for instance). The default size/shape of the export video is set by the video or image in track 1 (or track 2 if there's no background image/video in track 1). If you get low quality or output of the wrong size I recommend going to File>Project Settings>Video and setting the preserved video size to what you want (such as 1920 x 1080) and you might find it helps to tick "Always resize video sources..." and "Always resize video output...". It is possible to use automation on the parameters if you want to get fancy. Enjoy!

Code:
// Grid of videos - automatically draws any number of videos from tracks with grid 

//@param 1:boss "Lead Video Track" 2 1 11 6 1
//@param 2:Nbig "Lead Video Width" 1 1 9 5 1
//@param 3:yposratio "Y Offset" 0 0 1 0.5 0.01
//@param 4:border "Grid Borders" 5 0 100 50 1
//@param 5:presasp "Preserve Aspect" 0 0 1 0.5 1
//@param 6:portrait "Landscape or Portrait" 0 0 1 0.5 1
//@param 7:background "Backdrop Color/Video" 1 0 1 0.5 1
//@param 8:R "Backdrop Red" 0 0 1 0.5 0.01
//@param 9:G "Backdrop Green" 0 0 1 0.5 0.01
//@param 10:B "Backdrop Blue" 0 0 1 0.5 0.01

boss = boss - 1; // boss is now relative to video processor track 
Ntracks = input_track_count(); // Number of video files
boss>Ntracks ? boss = Ntracks; // If the lead video track set is greater than Ntracks use last
gfx_set(0);
gfx_fillrect(0,0,project_w,project_h);
x=0;
Ntracks > 0 // If there are video tracks then get nonzero number of grid locations
?
count_tracks = Ntracks + Nbig^2 - 1 // Number of grid locations filled
: //else no grid
count_tracks = 0  
;
aspect = project_w/project_h;
portrait == 0 
?// if landscape source videos
(
 xoffset = 0;
 border_h = border;
 border_w = border*aspect;
 height = project_h - border_h;
 width = project_w - border_w;
 cols = ceil(sqrt(count_tracks));
 rows = ceil(count_tracks/cols);
 vHeight = height / cols - border_h;  // Video height including half border*aspect each side
 vWidth = width / cols - border_w;    // Video Width including half border*aspect each side
)
: // else we assume portrait source videos need to be fitted into landscape output
(
 border_h = border*aspect;
 border_w = border;
 height = project_h - border_h;
 width = project_w - border_w;
 rows = ceil((sqrt(count_tracks))/aspect);
 cols = ceil(count_tracks/rows);
 rows_alt = rows - 1;
 cols_alt = ceil(count_tracks/rows_alt);
 rows*(aspect^2)>cols_alt ? (cols = cols_alt;rows = rows_alt;); // if reducing rows by one is more efficient 
 rows<Nbig ? (rows = Nbig; cols = ceil(count_tracks/rows);); // if number of rows is less than Nbig
 vWidth = width / cols - border_w;    // Video Width
 vHeight = height / rows - border_h;  // Video Height
 aspect < (vHeight/vWidth) // if fitting to width andѿ not tall enough
  ?      
  (xoffset = 0;
   vHeight = vWidth*aspect;)  // Replace video Height
  : // else fitting to height and not wide enough
   (vWidth = vHeight / aspect;  // Replace video Width
   xoffset = (project_w - (cols*vWidth + (cols+1)*border_w))/2;)   
 );
Nbig>1 ? // if one of the videos is chosen to be big
(
left_cols = floor((cols - Nbig)/2); // Number of columns before big central video
top_rows = floor((rows - Nbig)/2); // Number of rows before big central video
)
:
(
left_cols = 0;
top_rows = 0;
);
background == 1 
? 
 gfx_blit(0) // Show current track image or video as background
:
(
 gfx_set(R,G,B,1);
 gfx_fillrect(0,0,project_w,project_h); // Show color as background
);
bosscount = 0; // Counter for taking into account grid positions for boss video 
ypos = yposratio*project_h;
  loop(count_tracks,
  row = floor(x/cols); // Column position (starts at 0)
  col = x % cols;           // Row position (starts at 0)
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  //lastLineOffset = (width - width/cols * lastLineCount) / 2 ;
  lastLineOffset = (project_w - (lastLineCount*vWidth + (lastLineCount+1)*border_w))/2;
  ((x >= (cols*rows - cols))&(bosscount == Nbig^2))                             // Is it the last line?
    ? xpos = col*vwidth + lastLineOffset + border_w*col     // x position last line
    : xpos = col*vwidth + border_w*col + xoffset       // x position non-last line
    ;
 ((row>top_rows-1)&(col>left_cols-1)&(row<top_rows+Nbig)&(col<left_cols+Nbig))
    ? // if the grid number corresponds to being part of the big video
    (
    ((bosscount == 0)&(boss>0)) // if its the first of the big video then plot it
    ?
    (
      gfx_blit(
        input_track(boss-1),
        presasp,                                   // preserve aspect ratio
        border_w + xpos,                                  // X position
        border_h + vheight*(row) + border_h*(row) + ypos, // Y position
        Nbig*vwidth+(Nbig-1)*border_w,Nbig*vheight+(Nbig-1)*border_h // output width and height
      );
    );
      bosscount = bosscount + 1; // increment counter
    )
    : // else if the grid number is not part of the big video
    x-bosscount+1 < Ntracks // if this video number exists
    ?
    (vidnum = x-bosscount+1;
      vidnum < boss ? vidnum = vidnum-1;
    gfx_blit(
      input_track(vidnum), 
      presasp,                                   // preserve aspect ratio
      border_w + xpos,                                  // X position
      border_h + vheight*(row) + border_h*(row) + ypos, // Y position
      vwidth,vheight               // output width and height
    );
    );
  x += 1;
);

Last edited by jak352; 05-10-2020 at 01:30 PM. Reason: corrected missing xoffset = 0; for landscape videos
jak352 is offline   Reply With Quote
Old 05-11-2020, 02:00 AM   #34
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default Version of the code allowing for lead track to be expanded

Here's more revised code. If you want a large gap in the grid to allow a big bit of background video/image to be revealled then make "Expand Lead Track" to 1 and leave "Lead to Front on 0" and increase "Lead Video Width" to taste. This will allow the video on the Lead Track number of your choice to display in the backround instead of being resized within the grid (as long as you leave Track 1 empty of video/images).

You can choose to optimise for landscape or portrait source videos using a dial (assuming landscape output). It can now allow you to specify a background colour too (if Expand Background Video is 0). As before it allows for a larger video within the grid. With "Lead Video Width" set to 2 then the lead video (which can be chosen using "Lead Video Track" dial) will be twice as wide/tall and placed centrally and so on. Any number of videos then fit around it. You can also drag the y position of the whole thing using "Y Offset". Border size is set with "Grid Borders". Setting "Preserve Aspect" to 0 means videos/images will be stretched to fit the grid which can be helpful to get rid of any black spaces.

Just place this code in the Video Processor in track 1. Put the videos you want in the grid in tracks 2 onwards. If you want a background image or background video (visible for non-zero Grid Borders values when Expand Lead Track is 0) while still preserving the video on track 2 within the grid then put an image or video in track 1 and set Background Color/Video to 1. Leave Background Color/Video on 0 if you want to specify a backround color using the RGB knobs instead. Images count as if they are videos and image items can be resized to fill space (to ensure tracks don't hop around if you don't want them to for instance). The default size/shape of the export video is set by the video or image in track 1 (or track 2 if there's no background image/video in track 1). If you get low quality or output of the wrong size I recommend going to File>Project Settings>Video and setting the preserved video size to what you want (such as 1920 x 1080) and you might find it helps to tick "Always resize video sources..." and "Always resize video output...". It is possible to use automation on the parameters if you want to get fancy. Enjoy!

Code:
// Grid of videos - automatically draws any number of videos from tracks with grid 

//@param 1:boss "Lead Video Track" 2 2 10 6 1
//@param 2:Nbig "Lead Video Width" 1 1 9 5 1
//@param 3:yposratio "Y Offset" 0 0 1 0.5 0.01
//@param 4:border "Grid Borders" 5 0 100 50 1
//@param 5:presasp "Preserve Aspect" 0 0 1 0.5 1
//@param 6:portrait "Landscape or Portrait" 0 0 1 0.5 1
//@param 7:background "Backdrop Color/Video" 1 0 1 0.5 1
//@param 8:R "Backdrop Red" 0 0 1 0.5 0.01
//@param 9:G "Backdrop Green" 0 0 1 0.5 0.01
//@param 10:B "Backdrop Blue" 0 0 1 0.5 0.01
//@param 11:bossexpand "Expand Lead Track" 0 0 1 0.5 1
//@param 12:bossfront "Lead to Front" 0 0 1 0.5 1

aspect = project_w/project_h; // aspect ratio of project
boss = boss - 1; // boss is now relative to video processor track
ypos = yposratio*project_h;
((boss>0)&(bossexpand==1)&(bossfront==1)) ? // if there is a lead track on front then plot it
      gfx_blit(
        input_track(boss-1),
        presasp,                                   // preserve aspect ratio
        0,                                  // X position
        0, // Y position
        project_w,project_h // output width and height
      )
: // if there isn't a lead track on front then do the rest of the code
(
 Ntracks = input_track_count(); // Number of video files
 boss>Ntracks ? boss = Ntracks; // If the lead video track set is greater than Ntracks use last
 gfx_set(0);
 gfx_fillrect(0,0,project_w,project_h);
 x=0; // Counter for looping through grid entries
 Ntracks > 0 // If there are video tracks then get nonzero number of grid locations
 ?
 count_tracks = Ntracks + Nbig^2 - 1 // Number of grid locations filled
 : //else no grid
 count_tracks = 0  
 ;
 portrait == 0 
 ?// if landscape source videos
 (
  xoffset = 0;
  border_h = border;
  border_w = border*aspect;
  height = project_h - border_h;
  width = project_w - border_w;
  cols = ceil(sqrt(count_tracks));
  rows = ceil(count_tracks/cols);
  vHeight = height / cols - border_h;  // Video height including half border*aspect each side
  vWidth = width / cols - border_w;    // Video Width including half border*aspect each side
 )
 : // else we assume portrait source videos need to be fitted into landscape output
 (
  border_h = border*aspect;
  border_w = border;
  height = project_h - border_h;
  width = project_w - border_w;
  rows = ceil((sqrt(count_tracks))/aspect);
  cols = ceil(count_tracks/rows);
  rows_alt = rows - 1;
  cols_alt = ceil(count_tracks/rows_alt);
  rows*(aspect^2)>cols_alt ? (cols = cols_alt;rows = rows_alt;); // if reducing rows by one is more efficient 
  rows<Nbig ? (rows = Nbig; cols = ceil(count_tracks/rows);); // if number of rows is less than Nbig
  vWidth = width / cols - border_w;    // Video Width
  vHeight = height / rows - border_h;  // Video Height
  aspect < (vHeight/vWidth) // if fitting to width andѿ not tall enough
  ?      
  (xoffset = 0;
   vHeight = vWidth*aspect;)  // Replace video Height
  : // else fitting to height and not wide enough
    (vWidth = vHeight / aspect;  // Replace video Width
    xoffset = (project_w - (cols*vWidth + (cols+1)*border_w))/2;)   
  );
 Nbig>1 ? // if one of the videos is chosen to be big
 (
 left_cols = floor((cols - Nbig)/2); // Number of columns before big central video
 top_rows = floor((rows - Nbig)/2); // Number of rows before big central video
 )
 :
 (
 left_cols = 0;
 top_rows = 0;
 );
 ((boss>0)&(bossexpand==1)&(bossfront==0)) ? // if there is a lead track at back then plot it
      gfx_blit(
        input_track(boss-1),
        presasp,                                   // preserve aspect ratio
        0,                                  // X position
        0, // Y position
        project_w,project_h // output width and height
  )
  :
  (
    background == 1 
    ? 
     gfx_blit(0) // If background is 1 then show current track image or video as background
    :
   (
    gfx_set(R,G,B,1);
    gfx_fillrect(0,0,project_w,project_h); // else show color as background
  );
 );
 bosscount = 0; // Counter for taking into account grid positions for boss video
 loop(count_tracks,
  row = floor(x/cols); // Column position (starts at 0)
  col = x % cols;           // Row position (starts at 0)
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  lastLineOffset = (project_w - (lastLineCount*vWidth + (lastLineCount+1)*border_w))/2;
  ((x >= (cols*rows - cols))&(bosscount == Nbig^2))                             // Is it the last line?
    ? xpos = col*vWidth + lastLineOffset + border_w*col     // x position last line
    : xpos = col*vWidth + border_w*col + xoffset       // x position non-last line
    ;
 ((row>top_rows-1)&(col>left_cols-1)&(row<top_rows+Nbig)&(col<left_cols+Nbig))
    ? // if the grid number corresponds to being part of the big video
    (
    ((bosscount == 0)&(boss>0)&(bossexpand!=1)) // if its the first of the big video then plot it
    ?
    (
      gfx_blit(
        input_track(boss-1),
        presasp,                                   // preserve aspect ratio
        border_w + xpos,                                  // X position
        border_h + vHeight*(row) + border_h*(row) + ypos, // Y position
        Nbig*vWidth+(Nbig-1)*border_w,Nbig*vHeight+(Nbig-1)*border_h // output width and height
      );
    );
      bosscount = bosscount + 1; // increment counter
    )
    : // else if the grid number is not part of the big video
    x-bosscount+1 < Ntracks // if this video number exists
    ?
    (vidnum = x-bosscount+1;
      vidnum < boss ? vidnum = vidnum-1;
    gfx_blit(
      input_track(vidnum), 
      presasp,                                   // preserve aspect ratio
      border_w + xpos,                                  // X position
      border_h + vHeight*(row) + border_h*(row) + ypos, // Y position
      vWidth,vHeight               // output width and height
    );
    );
  x += 1;
 );
);

Last edited by jak352; 05-13-2020 at 10:37 AM. Reason: Changed description to make it clear you can change background track and made use of case consistent
jak352 is offline   Reply With Quote
Old 05-13-2020, 12:51 PM   #35
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default Version of the code allwoing for lead track to be expanded continuously

Here's a version that allows for the lead track to resize continuously. Set "Expand Lead Track" to 0 and the lead track fits in the grid. Set "Expand Lead Track" to 1" and the lead track fills the whole video window (behind the other videos if "Lead to Front" is set to 0). You can use automation to make "Expand Lead Track" zoom between 0 and 1 for a cool effect during playback. Leaving "Expand Lead Track" set to 0 makes more sense if making a grid from portrait source videos.

You can choose to optimise for landscape or portrait source videos using the dial (assuming landscape output). With "Lead Video Width" set to 2 then the lead video (which can be chosen using "Lead Video Track" dial) will be twice as wide/tall and placed centrally and so on. Any number of videos then fit around it. You can also drag the y position of the whole thing using "Y Offset". Border size is set with "Grid Borders". Setting "Preserve Aspect" to 1 means videos/images will be stretched to fit the grid which can be helpful to get rid of any black spaces.

Just place this code in the Video Processor in track 1. Put the videos you want in the grid in tracks 2 onwards. If you want a background image or background video (visible for non-zero Grid Borders values when Expand Lead Track is less than 1) while still preserving the video on the lead track within the grid then put an image or video in track 1 and set Background Color/Video to 1. Leave Background Color/Video on 0 if you want to specify a backround color using the RGB knobs instead. Images count as if they are videos and image items can be resized to fill space (to ensure tracks don't hop around if you don't want them to for instance). The default size/shape of the export video is set by the video or image in track 1 or track 2 if there's no background image/video in track 1. If you get low quality or output of the wrong size I recommend going to File>Project Settings>Video and setting the preserved video size to what you want (such as 1920 x 1080) and you might find it helps to tick "Always resize video sources..." and "Always resize video output...". It is possible to use automation on any of the parameters if you want to get fancy. Enjoy!

Code:
// Grid of videos - automatically draws any number of videos from tracks with grid 

//@param 1:boss "Lead Video Track" 2 2 10 6 1
//@param 2:Nbig "Lead Video Width" 1 1 9 5 1
//@param 3:yposratio "Y Offset" 0 0 1 0.5 0.01
//@param 4:border "Grid Borders" 5 0 100 50 1
//@param 5:presasp "Preserve Aspect" 1 0 1 0.5 1
//@param 6:portrait "Landscape or Portrait" 0 0 1 0.5 1
//@param 7:background "Backdrop Color/Video" 0 0 1 0.5 1
//@param 8:R "Backdrop Red" 0.1 0 1 0.5 0.01
//@param 9:G "Backdrop Green" 0.1 0 1 0.5 0.01
//@param 10:B "Backdrop Blue" 0.5 0 1 0.5 0.01
//@param 11:bossexpand "Expand Lead Track" 0 0 1 0.5 0.01
//@param 12:bossfront "Lead to Front" 0 0 1 0.5 1

aspect = project_w/project_h; // aspect ratio of project
boss = boss - 1; // boss is now relative to video processor track
ypos = yposratio*project_h;
((boss>0)&(bossexpand==1)&(bossfront==1)) ? // if there is a lead track fully expanded on front then plot it
      gfx_blit(
        input_track(boss-1),
        presasp,                                   // preserve aspect ratio
        0,                                  // X position
        0, // Y position
        project_w,project_h // output width and height
      )
: // if there isn't a lead track on front then do the rest of the code
(
 Ntracks = input_track_count(); // Number of video files
 boss>Ntracks ? boss = Ntracks; // If the lead video track set is greater than Ntracks use last
 gfx_set(0);
 gfx_fillrect(0,0,project_w,project_h);
 x=0; // Counter for looping through grid entries
 Ntracks > 0 // If there are video tracks then get nonzero number of grid locations
 ?
 count_tracks = Ntracks + Nbig^2 - 1 // Number of grid locations filled
 : //else no grid
 count_tracks = 0  
 ;
 portrait == 0 
 ?// if landscape source videos
 (
  xoffset = 0;
  border_h = border;
  border_w = border*aspect;
  height = project_h - border_h;
  width = project_w - border_w;
  cols = ceil(sqrt(count_tracks));
  rows = ceil(count_tracks/cols);
  vHeight = height / cols - border_h;  // Video height including half border*aspect each side
  vWidth = width / cols - border_w;    // Video Width including half border*aspect each side
 )
 : // else we assume portrait source videos need to be fitted into landscape output
 (
  border_h = border*aspect;
  border_w = border;
  height = project_h - border_h;
  width = project_w - border_w;
  rows = ceil((sqrt(count_tracks))/aspect);
  cols = ceil(count_tracks/rows);
  rows_alt = rows - 1;
  cols_alt = ceil(count_tracks/rows_alt);
  rows*(aspect^2)>cols_alt ? (cols = cols_alt;rows = rows_alt;); // if reducing rows by one is more efficient 
  rows<Nbig ? (rows = Nbig; cols = ceil(count_tracks/rows);); // if number of rows is less than Nbig
  vWidth = width / cols - border_w;    // Video Width
  vHeight = height / rows - border_h;  // Video Height
  aspect < (vHeight/vWidth) // if fitting to width and not tall enough
  ?      
  (xoffset = 0;
   vHeight = vWidth*aspect;)  // Replace video Height
  : // else fitting to height and not wide enough
    (vWidth = vHeight / aspect;  // Replace video Width
    xoffset = (project_w - (cols*vWidth + (cols+1)*border_w))/2;)   
  );
 Nbig>1 ? // if one of the videos is chosen to be big
 (
 left_cols = floor((cols - Nbig)/2); // Number of columns before big central video
 top_rows = floor((rows - Nbig)/2); // Number of rows before big central video
 )
 :
 (
 left_cols = 0;
 top_rows = 0;
 );
background == 1 
    ? 
     gfx_blit(0) // If background is 1 then show current track image or video as background
    :
   (
    gfx_set(R,G,B,1);
    gfx_fillrect(0,0,project_w,project_h); // else show color as background
  
 );
 // if the lead track is behind plot it first
 bossfront==0
 ?
 (
  xpos = left_cols*vWidth + border_w*left_cols + xoffset; //xpos for boss if in front
  gfx_blit(
         input_track(boss-1),
         presasp,                                   // preserve aspect ratio
         (1-bossexpand)*(border_w + xpos),                                  // X position
         (1-bossexpand)*(border_h + vHeight*(top_rows) + border_h*(top_rows) + ypos), // Y position
         (1-bossexpand)*(Nbig*vWidth+(Nbig-1)*border_w) + bossexpand*project_w,
         (1-bossexpand)*(Nbig*vHeight+(Nbig-1)*border_h) + bossexpand*project_h // output width and height
       );
 );
 bosscount = 0; // Counter for taking into account grid positions for boss video
 loop(count_tracks,
  row = floor(x/cols); // Column position (starts at 0)
  col = x % cols;           // Row position (starts at 0)
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  lastLineOffset = (project_w - (lastLineCount*vWidth + (lastLineCount+1)*border_w))/2;
  ((x >= (cols*rows - cols))&(bosscount == Nbig^2))                             // Is it the last line?
    ? xpos = col*vWidth + lastLineOffset + border_w*col     // x position last line
    : xpos = col*vWidth + border_w*col + xoffset       // x position non-last line
    ;
   ((row>top_rows-1)&(col>left_cols-1)&(row<top_rows+Nbig)&(col<left_cols+Nbig))
   ? // if the grid number corresponds to being part of the big video
      bosscount = bosscount + 1 // increment counter
    : // else if the grid number is not part of the big video
    x-bosscount+1 < Ntracks // if this video number exists
    ?
    (vidnum = x-bosscount+1;
      vidnum < boss ? vidnum = vidnum-1;
     gfx_blit(
      input_track(vidnum), 
      presasp,                                   // preserve aspect ratio
      border_w + xpos,                                  // X position
      border_h + vHeight*(row) + border_h*(row) + ypos, // Y position
      vWidth,vHeight               // output width and height
    );
   );
  x += 1;
 ); //End of main loop
 bossfront==1 //If the boss is in front of everything else plot it now
  ?
  (
 xpos = left_cols*vWidth + border_w*left_cols + xoffset; //xpos for boss if in front
 gfx_blit(
         input_track(boss-1),
         presasp,                                   // preserve aspect ratio
         (1-bossexpand)*(border_w + xpos),                                  // X position
         (1-bossexpand)*(border_h + vHeight*(top_rows) + border_h*(top_rows) + ypos), // Y position
         (1-bossexpand)*(Nbig*vWidth+(Nbig-1)*border_w) + bossexpand*project_w,
         (1-bossexpand)*(Nbig*vHeight+(Nbig-1)*border_h) + bossexpand*project_h // output width and height
       );
  );
);

Last edited by jak352; 05-13-2020 at 01:50 PM.
jak352 is offline   Reply With Quote
Old 05-13-2020, 02:11 PM   #36
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,293
Default

Would be great to see some of your versions in a video or gif example. Your stuff is a really nice addition to reaper video processor.

many thanks
Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is offline   Reply With Quote
Old 05-13-2020, 02:58 PM   #37
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Smile

Quote:
Originally Posted by Eliseat View Post
Would be great to see some of your versions in a video or gif example. Your stuff is a really nice addition to reaper video processor.

many thanks
Eli
Thanks! I'm planning another YouTube in the next few days!
jak352 is offline   Reply With Quote
Old 05-16-2020, 03:32 PM   #38
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,202
Default

Jonathan, a new video on its way with your code.

http://www.facebook.com/robi.petric/...2262859777788/

Made another one with professional superstar hornplayers as well few days ago.
Thanks!

youtu.be/DPazNSxDDbM
__________________
W10 (64) Lenovo E540 - SSD; Lenovo B590; W7 (32), Compaq 610 (2.1Ghz core 2 duo, L2 cache, 2GB RAM); DPA 4018, Schoeps MK2, Schoeps MTSC 64, Neumann mk184, AEA Ribbon 88mk, AKG SolidTUBE; Focusrite Scarlett 18i20, recording merely live acoustic music.

Last edited by urednik; 05-16-2020 at 04:21 PM.
urednik is offline   Reply With Quote
Old 05-17-2020, 12:28 AM   #39
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,293
Default

Quote:
Originally Posted by urednik View Post
Jonathan, a new video on its way with your code.

http://www.facebook.com/robi.petric/...2262859777788/

Made another one with professional superstar hornplayers as well few days ago.
Thanks!

youtu.be/DPazNSxDDbM
Amazing. I hope this finds its way to the devs to show how much potential Reapers video capabilities have.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is offline   Reply With Quote
Old 05-19-2020, 01:07 PM   #40
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 51
Default Version of the code used for YouTube "How To" video

Lead track can resize continuously. Set "Expand Lead Track" to 0 and the lead track fits in the grid. Set "Expand Lead Track" to 1" and the lead track fills the whole video window (behind the other videos if "Lead to Front" is set to 0 and this is handy when you have "Lead Grid Size" greater than 1). You can use automation to make "Expand Lead Track" zoom between 0 and 1 for a cool effect during playback. Leaving "Expand Lead Track" set to 0 makes more sense if making a grid from portrait source videos.

You can choose to optimise for landscape or portrait source videos using the dial (and this code assumes landscape output). With "Lead Grid Size" set to 2 then the lead video (which can be chosen using "Lead Track Number" dial) will be twice as wide/tall and placed centrally and so on. Any number of videos then fit around it. You can also drag the y position of the whole thing using "Y Offset". Border size is set with "Grid Borders". Setting "Preserve Aspect" to 1 means videos/images will be stretched to fit the grid which can be helpful to get rid of any black spaces.

Just place this code in the Video Processor in track 1. Put the videos you want in the grid in tracks 2 onwards. If you want a background image or background video (visible for non-zero Grid Borders values when Expand Lead Track is less than 1) while still preserving the video on the lead track within the grid then put an image or video in track 1 and set Background Color/Video to 1. Leave Background Color/Video on 0 if you want to specify a backround color using the RGB knobs instead. Images count as if they are videos and image items can be resized to fill space (to ensure tracks don't hop around if you don't want them to for instance). The default size/shape of the export video is set by the video or image in track 1 or track 2 if there's no background image/video in track 1. If you get low quality or output of the wrong size I recommend going to File>Project Settings>Video and setting the preserved video size to what you want (such as 1920 x 1080) and you might find it helps to tick "Always resize video sources..." and "Always resize video output...". It is possible to use automation on any of the parameters if you want to get fancy. Enjoy!

Code:
// Grid of videos - automatically draws any number of videos from tracks with grid 

//@param 1:boss "Lead Track Number" 2 2 10 6 1
//@param 2:Nbig "Lead Grid Size" 1 1 9 5 1
//@param 3:bossexpand "Expand Lead Track" 0 0 1 0.5 0.01
//@param 4:bossfront "Lead to Front" 0 0 1 0.5 1
//@param 5:yposratio "Y Offset" 0 0 1 0.5 0.01
//@param 6:border "Grid Borders" 5 0 720 360 1
//@param 7:presasp "Preserve Aspect" 1 0 1 0.5 1
//@param 8:portrait "Landscape or Portrait" 0 0 1 0.5 1
//@param 9:background "Backdrop Color/Video" 0 0 1 0.5 1
//@param 10:R "Backdrop Red" 0.1 0 1 0.5 0.01
//@param 11:G "Backdrop Green" 0.1 0 1 0.5 0.01
//@param 12:B "Backdrop Blue" 0.5 0 1 0.5 0.01

aspect = project_w/project_h; // aspect ratio of project
boss = boss - 1; // boss is now relative to video processor track
ypos = yposratio*project_h;
 Ntracks = input_track_count(); // Number of video files
 boss>Ntracks ? boss = Ntracks; // If the lead video track set is greater than Ntracks use last
((boss>0)&(bossexpand==1)&(bossfront==1)) ? // if there is a lead track fully expanded on front then plot it
      gfx_blit(
        input_track(boss-1),
        presasp,                                   // preserve aspect ratio
        0,                                  // X position
        0, // Y position
        project_w,project_h // output width and height
      )
: // if there isn't a lead track on front then do the rest of the code
(
 gfx_set(0);
 gfx_fillrect(0,0,project_w,project_h);
 x=0; // Counter for looping through grid entries
 Ntracks > 0 // If there are video tracks then get nonzero number of grid locations
 ?
 count_tracks = Ntracks + Nbig^2 - 1 // Number of grid locations filled
 : //else no grid
 count_tracks = 0  
 ;
 portrait == 0 
 ?// if landscape source videos
 (
  xoffset = 0;
  border_h = border;
  border_w = border*aspect;
  height = project_h - border_h;
  width = project_w - border_w;
  cols = ceil(sqrt(count_tracks));
  rows = ceil(count_tracks/cols);
  vHeight = height / cols - border_h;  // Video height including half border*aspect each side
  vWidth = width / cols - border_w;    // Video Width including half border*aspect each side
 )
 : // else we assume portrait source videos need to be fitted into landscape output
 (
  border_h = border*aspect;
  border_w = border;
  height = project_h - border_h;
  width = project_w - border_w;
  rows = ceil((sqrt(count_tracks))/aspect);
  cols = ceil(count_tracks/rows);
  rows_alt = rows - 1;
  cols_alt = ceil(count_tracks/rows_alt);
  rows*(aspect^2)>cols_alt ? (cols = cols_alt;rows = rows_alt;); // if reducing rows by one is more efficient 
  rows<Nbig ? (rows = Nbig; cols = ceil(count_tracks/rows);); // if number of rows is less than Nbig
  vWidth = width / cols - border_w;    // Video Width
  vHeight = height / rows - border_h;  // Video Height
  aspect < (vHeight/vWidth) // if fitting to width and not tall enough
  ?      
  (xoffset = 0;
   vHeight = vWidth*aspect;)  // Replace video Height
  : // else fitting to height and not wide enough
    (vWidth = vHeight / aspect;  // Replace video Width
    xoffset = (project_w - (cols*vWidth + (cols+1)*border_w))/2;)   
  );
 Nbig>1 ? // if one of the videos is chosen to be big then put lead track in centre
 (
 left_cols = floor((cols - Nbig)/2); // Number of columns before big central video
 top_rows = floor((rows - Nbig)/2); // Number of rows before big central video
 )
 : // else all videos same size then lead tracks stays where it is
 (
 top_rows = floor((boss-1)/cols);
 left_cols = (boss-1) % cols;
 );
background == 1 
    ? 
     gfx_blit(0) // If background is 1 then show current track image or video as background
    :
   (
    gfx_set(R,G,B,1); //Set color for background
    gfx_fillrect(0,0,project_w,project_h); // show color as background
 );
 bossfront==0 // if the lead track is behind plot it first
 ?
 (
   (boss-1 >= (cols*rows - cols))                             // Is it the last line?
     ? 
      (
       lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
       lastLineOffset = (project_w - (lastLineCount*vWidth + (lastLineCount+1)*border_w))/2;
       xpos = left_cols*vWidth + lastLineOffset + border_w*left_cols;     // x position last line
      )
     : 
      xpos = left_cols*vWidth + border_w*left_cols + xoffset;       // x position non-last line
     gfx_blit(
      input_track(boss-1),
      presasp,                                   // preserve aspect ratio
      (1-bossexpand)*(border_w + xpos),                                  // X position
      (1-bossexpand)*(border_h + vHeight*(top_rows) + border_h*(top_rows) + ypos), // Y position
      (1-bossexpand)*(Nbig*vWidth+(Nbig-1)*border_w) + bossexpand*project_w,
      (1-bossexpand)*(Nbig*vHeight+(Nbig-1)*border_h) + bossexpand*project_h // output width and height
      );
 );
 bosscount = 0; // Counter for taking into account grid positions for boss video
 loop(count_tracks, //main loop for plotting grid
  row = floor(x/cols); // Column position (starts at 0)
  col = x % cols;           // Row position (starts at 0)
  lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
  lastLineOffset = (project_w - (lastLineCount*vWidth + (lastLineCount+1)*border_w))/2;
  ((x >= (cols*rows - cols))&(bosscount > Nbig^2 - 2)) // Is it the last line and after any big video?
    ? xpos = col*vWidth + lastLineOffset + border_w*col     // x position last line
    : xpos = col*vWidth + border_w*col + xoffset       // x position non-last line
    ;
   ((row>top_rows-1)&(col>left_cols-1)&(row<top_rows+Nbig)&(col<left_cols+Nbig))
   ? // if the grid number corresponds to being part of the big video
      bosscount = bosscount + 1 // increment counter
    : // else if the grid number is not part of the big video
    x-bosscount+1 < Ntracks // if this video number exists
    ?
    (vidnum = x-bosscount+1;
      vidnum < boss ? vidnum = vidnum-1;
     gfx_blit(
      input_track(vidnum), 
      presasp,                                   // preserve aspect ratio
      border_w + xpos,                                  // X position
      border_h + vHeight*(row) + border_h*(row) + ypos, // Y position
      vWidth,vHeight               // output width and height
    );
   );
  x += 1;
 ); //End of main loop
 bossfront==1 //If the boss is in front of everything else plot it now
  ?
  (
   (boss-1 >= (cols*rows - cols)) // Is it the last line?
       ? 
        (
         lastLineCount = (count_tracks-1) % cols + 1; // Number of videos in last row
         lastLineOffset = (project_w - (lastLineCount*vWidth + (lastLineCount+1)*border_w))/2;
         xpos = left_cols*vWidth + lastLineOffset + border_w*left_cols;     // x position last line
        )
       : //else not the last line
        xpos = left_cols*vWidth + border_w*left_cols + xoffset;       // x position non-last line
      gfx_blit(
       input_track(boss-1),
       presasp,                                   // preserve aspect ratio
       (1-bossexpand)*(border_w + xpos),                                  // X position
       (1-bossexpand)*(border_h + vHeight*(top_rows) + border_h*(top_rows) + ypos), // Y position
       (1-bossexpand)*(Nbig*vWidth+(Nbig-1)*border_w) + bossexpand*project_w,
       (1-bossexpand)*(Nbig*vHeight+(Nbig-1)*border_h) + bossexpand*project_h // output width and height
      );
  );
);
jak352 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.