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

Reply
 
Thread Tools Display Modes
Old 05-19-2020, 03:56 PM   #41
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 48
Smile My new YouTube "How to make a Virtual Choir or Virtual Band Video in Reaper"

It's great to see this stuff being used! This new YouTube uses my new version of the code from post number 40:
jak352 is offline   Reply With Quote
Old 05-20-2020, 12:51 AM   #42
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,071
Default

Quote:
Originally Posted by urednik View Post
Made another one with professional superstar hornplayers as well few days ago.
Thanks!

youtu.be/DPazNSxDDbM
This is so nice!!! Great video! Well done!! I Love it!
amagalma is offline   Reply With Quote
Old 05-20-2020, 04:23 AM   #43
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,233
Default

Quote:
Originally Posted by jak352 View Post
It's great to see this stuff being used! This new YouTube uses my new version of the code from post number 40:
Jak352,

this is really great. Didn't know you already had so many features added to your script. Many thanks for the video and the script.

This is a new level in Reaper video editing.

Greetings
Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is online now   Reply With Quote
Old 05-20-2020, 05:18 AM   #44
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,071
Default

Thank you jak352 for the great script!!
amagalma is offline   Reply With Quote
Old 05-20-2020, 05:23 AM   #45
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 5,311
Default

Quote:
Originally Posted by jak352 View Post
It's great to see this stuff being used! This new YouTube uses my new version of the code from post number 40:
Very smart script! Thanks! A little tip: you don't have to disable snapping, if you want move something ignoring it. Just Use Shift + left drag (by default) to move items ignoring snapping.
__________________
Quote:
Originally Posted by Sexan View Post
Make a thread "F%#! you Reaper! I quit!" to get more views and feedback since these kind of threads get much more traction
SoundCloudFR: True Non-destructive GLUEAll the REAPER names
vitalker is offline   Reply With Quote
Old 05-21-2020, 05:56 AM   #46
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 48
Default

Awesome! Thanks for the feedback. Here's a little script for converting landscape videos to portrait. This would be useful when making a virtual choir of portrait mode videos using my code and one choir member sends a landscape. Go to the offending track and instead using opacity/zoom/pan in the Video Processor for that track use the code below. This is relevant to 37 minutes into my video when I got stuck:

Code:
//Convert landscape to portrait
input_info(0,prewidth,preheight);
preaspect = prewidth/preheight;
preserveaspect = 0;
destx = 0;//destination x
desty = 0;//destination y
destw = project_w;//destination width
desth = project_h;//destination height
srcx = (prewidth-(preheight/preaspect))/2;//source x
srcy = 0;//source y
srcw = preheight/preaspect;//source width
srch = preheight;//source height
gfx_blit(0, preserveaspect, destx, desty, destw, desth, srcx, srcy, srcw, srch);
jak352 is offline   Reply With Quote
Old 05-21-2020, 03:50 PM   #47
Joshua Unitt
Human being with feelings
 
Join Date: Mar 2018
Posts: 5
Default

Hey folks, has anyone had any issues with videos that were not pixelated/blurry, becoming pixelated/blurry when used with this code? I don't think the code is the underlying problem, I feel it might be a settings or playback issue for me. But I'm curious if anyone else has had this happen and what they might have done to overcome it!
Joshua Unitt is offline   Reply With Quote
Old 05-22-2020, 12:58 AM   #48
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 48
Default

Quote:
Originally Posted by Joshua Unitt View Post
Hey folks, has anyone had any issues with videos that were not pixelated/blurry, becoming pixelated/blurry when used with this code? I don't think the code is the underlying problem, I feel it might be a settings or playback issue for me. But I'm curious if anyone else has had this happen and what they might have done to overcome it!
If there is low quality in the video window within Reaper try going to
File>Project Settings>Video
and then enter the preferred video size (say 1920 x 1080) and tick all the boxes. Does that help? If the only problem is the quality of the output file on rendering you can also specify various settings including kbps in the render dialogue.
jak352 is offline   Reply With Quote
Old 05-23-2020, 12:13 AM   #49
zacki
Human being with feelings
 
zacki's Avatar
 
Join Date: Feb 2013
Location: Germany
Posts: 159
Thumbs up

Thanks a lot, jak! Great script!

Quote:
Originally Posted by urednik View Post
Made another one with professional superstar hornplayers as well few days ago.
Thanks!

youtu.be/DPazNSxDDbM
wow, I mean... WOW
__________________
Some of my favourite posts: 1 2 3 --- to be continued...
zacki is offline   Reply With Quote
Old 05-23-2020, 02:38 AM   #50
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,198
Default

Well thanks for nice comments on my video. Again, Jonathan, big thanks for helping us out with this code. One final video will use all of your recent tweaks of course!
__________________
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.
urednik is offline   Reply With Quote
Old 05-23-2020, 10:44 AM   #51
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 48
Cool Revised code with option to crop videos automatically and approximately square grid

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 "Stretch/Crop/Full" 0.5 0 1 0.5 0.5
//@param 8:portrait "Landscape/Sq/Portrait" 0 0 1 0.5 0.5
//@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

presasp == 0.5 ? (crop = 1; presasp = 0) : crop = 0; //presasp = 0.5 means crop videos
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
(
            crop == 1 ? //crop code
            (
            input_info(input_track(boss-1),prewidth,preheight);
            project_w/project_h<prewidth/preheight ? //crop from width
             (wsrc_expand = (preheight*(project_w/project_h));//source width
              hsrc_expand = preheight;//source height
              xsrc_expand = (prewidth - wsrc_expand)/2;//source x
              ysrc_expand = 0;)//source y
             : //else crop from height
              (wsrc_expand = prewidth;
              hsrc_expand = (prewidth*(project_h/project_w));
              xsrc_expand = 0;
              ysrc_expand = (preheight - hsrc_expand)/2;);
             )
             :
             (xsrc_expand = 0;ysrc_expand = 0;wsrc_expand = prewidth; hsrc_expand = preheight);
      gfx_blit(
        input_track(boss-1),
        presasp,// preserve aspect ratio
        0, 0, project_w, project_h, // output x, y, width and height
        xsrc_expand,ysrc_expand,wsrc_expand,hsrc_expand // source x, y, 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
 Ntracks > 0 // If there are video tracks
 ?
 count_tracks = Ntracks + Nbig^2 - 1 // Number of grid locations
 : //else
 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
  vWidth = width / cols - border_w; // Video Width
 )
 : portrait == 0.5 ? //else if sqaure grid
 (
  xoffset = 0;
  rows = ceil(sqrt(count_tracks/aspect));
  cols = ceil(count_tracks/rows);
  border_h = border;
  border_w = border*aspect*rows/cols;
  height = project_h - border_h;
  width = project_w - border_w;
  vHeight = height / rows - border_h;  
  vWidth = width / cols - border_w; 
 )
 : // else we assume portrait source videos
 (
  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 better 
  rows<Nbig ? (rows = Nbig; cols = ceil(count_tracks/rows);); // if number of rows is less than Nbig
  vWidth = width / cols - border_w;
  vHeight = height / rows - border_h;
  aspect < (vHeight/vWidth) // if fitting to width
   ?      
   (xoffset = 0;
   vHeight = vWidth*aspect;)
   : // else fitting to height
    (vWidth = vHeight / aspect;
    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
      input_info(input_track(boss-1),prewidth,preheight);
      xpos_expand = (1-bossexpand)*(border_w + xpos);
      ypos_expand = (1-bossexpand)*(border_h + vHeight*(top_rows) + border_h*(top_rows) + ypos);
      vWidth_expand = (1-bossexpand)*(Nbig*vWidth+(Nbig-1)*border_w) + bossexpand*project_w;
      vHeight_expand = (1-bossexpand)*(Nbig*vHeight+(Nbig-1)*border_h) + bossexpand*project_h;
      crop == 1 ? //crop code
      (
       vWidth_expand/vHeight_expand<prewidth/preheight ? //crop from width
       (wsrc_expand = (preheight*(vWidth_expand/vHeight_expand));//source width
        hsrc_expand = preheight;//source height
        xsrc_expand = (prewidth - wsrc_expand)/2;//source x
        ysrc_expand = 0;)//source y
       : //else
        (wsrc_expand = prewidth;
        hsrc_expand = (prewidth*(vHeight_expand/vWidth_expand));
        xsrc_expand = 0;
        ysrc_expand = (preheight - hsrc_expand)/2;);
        )
        :
        (
        xsrc_expand = 0;ysrc_expand = 0;wsrc_expand = prewidth; hsrc_expand = preheight;
        );
     //plot code
     gfx_blit(
      input_track(boss-1), presasp,
      xpos_expand, ypos_expand, vWidth_expand, vHeight_expand,
      xsrc_expand,ysrc_expand,wsrc_expand,hsrc_expand
      );
 );
 bosscount = 0; // Counter for taking into account boss video
 loop(count_tracks, //main loop
  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 // last line
    : xpos = col*vWidth + border_w*col + xoffset // non-last line
    ;
   ((row>top_rows-1)&(col>left_cols-1)&(row<top_rows+Nbig)&(col<left_cols+Nbig))
   ? // if the grid number is part of big video
      bosscount = bosscount + 1 // increment counter
    : // else
    x-bosscount+1 < Ntracks // if video exists
    ?
    (vidnum = x-bosscount+1;
      vidnum < boss ? vidnum = vidnum-1;
     //crop code
     input_info(input_track(vidnum),prewidth,preheight);
     vxpos = border_w + xpos; //x position
     vypos = border_h + vHeight*(row) + border_h*(row) + ypos; //y position
     crop == 1 ? //crop code
     (
     vWidth/vHeight<prewidth/preheight ? //crop from width
      (wsrc = preheight*(vWidth/vHeight);//source width
       hsrc = preheight;//source height
       xsrc = (prewidth - wsrc)/2;//source x
       ysrc = 0;)//source y
      : //else
       (wsrc = prewidth;
       hsrc = prewidth*(vHeight/vWidth);
       xsrc = 0;
       ysrc = (preheight - hsrc)/2;);
       )
       :
       (xsrc = 0; ysrc = 0; wsrc = prewidth; hsrc = preheight);
      //plot code
      gfx_blit(
        input_track(vidnum), presasp,
        vxpos, vypos, vWidth, vHeight,
        xsrc,ysrc,wsrc,hsrc
        );
   );
  x += 1;
 );
 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; // last line
        )
       : //else not the last line
        xpos = left_cols*vWidth + border_w*left_cols + xoffset; // non-last line
      //crop code
            input_info(input_track(boss-1),prewidth,preheight);
            xpos_expand = (1-bossexpand)*(border_w + xpos);
            ypos_expand = (1-bossexpand)*(border_h + vHeight*(top_rows) + border_h*(top_rows) + ypos);
            vWidth_expand = (1-bossexpand)*(Nbig*vWidth+(Nbig-1)*border_w) + bossexpand*project_w;
            vHeight_expand = (1-bossexpand)*(Nbig*vHeight+(Nbig-1)*border_h) + bossexpand*project_h;
            crop == 1 ? //crop code
             (
             vWidth_expand/vHeight_expand<prewidth/preheight ? //crop from width
             (wsrc_expand = (preheight*(vWidth_expand/vHeight_expand));//source width
              hsrc_expand = preheight;//source height
              xsrc_expand = (prewidth - wsrc_expand)/2;//source x
              ysrc_expand = 0;)//source y
             : //else
              (wsrc_expand = prewidth;
              hsrc_expand = (prewidth*(vHeight_expand/vWidth_expand));
              xsrc_expand = 0;
              ysrc_expand = (preheight - hsrc_expand)/2;);
              )
              :
              (
              xsrc_expand = 0; ysrc_expand = 0; wsrc_expand = prewidth; hsrc_expand = preheight;
              );
            gfx_blit(
               input_track(boss-1), presasp,
               xpos_expand, ypos_expand, vWidth_expand, vHeight_expand,
               xsrc_expand,ysrc_expand,wsrc_expand,hsrc_expand
            );
  );
);

Last edited by jak352; 05-23-2020 at 05:27 PM. Reason: Get rid of tiny lines around square videos
jak352 is offline   Reply With Quote
Old 05-23-2020, 12:31 PM   #52
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 48
Smile

The code in post 51 now has about all the features I was hoping for (I think). It now allows for automatically cropping the videos by using Fill/Crop/Full at 12 o'clock position (value 0.5) meaning you don't have to resize videos by ticking boxes in Project Settings or use opacity/zoom/pan unless you want to. Leaving it on value 0 means you don't preserve aspect ratio (stretching to fill) and value 1 means the entire video is fitted preserving aspect ratio (as before). There is a new option for having an approximately square grid (setting Landscape/Sq/Portrait at 12 o'clock position so value 0.5) and this is especially useful for projects where you crop both landscapes and portrait source videos. Values 0 and 1 are optimised for landscape and portrait source videos respectively (or vice versa if the project width and height are set to portrait mode for IGTV or whatever).

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 output...". It is possible to use automation on any of the parameters if you want to get fancy. Thanks for positive feedback and enjoy!
jak352 is offline   Reply With Quote
Old 05-23-2020, 04:40 PM   #53
Joshua Unitt
Human being with feelings
 
Join Date: Mar 2018
Posts: 5
Default

Quote:
Originally Posted by jak352 View Post
If there is low quality in the video window within Reaper try going to
File>Project Settings>Video
and then enter the preferred video size (say 1920 x 1080) and tick all the boxes. Does that help? If the only problem is the quality of the output file on rendering you can also specify various settings including kbps in the render dialogue.
preferred video size was the ticket. thank you so much!!!
Joshua Unitt is offline   Reply With Quote
Old 05-29-2020, 05:17 PM   #54
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,198
Default

Jak, hello. Just need some help please!
I would like lead video(s) to be displayed in the grid as well in order to keep things in place when switching them. How could I do that?
__________________
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.
urednik is offline   Reply With Quote
Old 05-31-2020, 02:17 AM   #55
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 48
Default

Quote:
Originally Posted by urednik View Post
Jak, hello. Just need some help please!
I would like lead video(s) to be displayed in the grid as well in order to keep things in place when switching them. How could I do that?
It is possible to rewrite the code to have the boss video doubled so it appears twice (once small in the grid and once big). A workaround with the current code is to just keep a single track as the lead track (ie. keeping "Lead Track Number" constant) and copying and pasting bits of video items to fill that track (using the S button to split items for copying for instance). You can make sure the copies don't cause double sound by clicking Route and unticking master send in the lead track (unless you already separated audio and video).
jak352 is offline   Reply With Quote
Old 06-01-2020, 01:02 AM   #56
jak352
Human being with feelings
 
Join Date: Apr 2017
Location: Scotland, UK
Posts: 48
Smile Version that has option "Lead Track Doubled" so things don't jump about when changing

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 "Stretch/Crop/Full" 0.5 0 1 0.5 0.5
//@param 8:portrait "Landscape/Sq/Portrait" 0 0 1 0.5 0.5
//@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
//@param 13:LeadDoubled "Lead Track Doubled" 0 0 1 0.5 1

presasp == 0.5 ? (crop = 1; presasp = 0) : crop = 0; //presasp = 0.5 means crop videos
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
(
            crop == 1 ? //crop code
            (
            input_info(input_track(boss-1),prewidth,preheight);
            project_w/project_h<prewidth/preheight ? //crop from width
             (wsrc_expand = (preheight*(project_w/project_h));//source width
              hsrc_expand = preheight;//source height
              xsrc_expand = (prewidth - wsrc_expand)/2;//source x
              ysrc_expand = 0;)//source y
             : //else crop from height
              (wsrc_expand = prewidth;
              hsrc_expand = (prewidth*(project_h/project_w));
              xsrc_expand = 0;
              ysrc_expand = (preheight - hsrc_expand)/2;);
             )
             :
             (xsrc_expand = 0;ysrc_expand = 0;wsrc_expand = prewidth; hsrc_expand = preheight);
      gfx_blit(
        input_track(boss-1),
        presasp,// preserve aspect ratio
        0, 0, project_w, project_h, // output x, y, width and height
        xsrc_expand,ysrc_expand,wsrc_expand,hsrc_expand // source x, y, 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
 Ntracks > 0 // If there are video tracks
 ?
 count_tracks = Ntracks + Nbig^2 - 1 + LeadDoubled// Number of grid locations
 : //else
 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
  vWidth = width / cols - border_w; // Video Width
 )
 : portrait == 0.5 ? //else if sqaure grid
 (
  xoffset = 0;
  rows = ceil(sqrt(count_tracks/aspect));
  cols = ceil(count_tracks/rows);
  border_h = border;
  border_w = border*aspect*rows/cols;
  height = project_h - border_h;
  width = project_w - border_w;
  vHeight = height / rows - border_h;  
  vWidth = width / cols - border_w; 
 )
 : // else we assume portrait source videos
 (
  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 better 
  rows<Nbig ? (rows = Nbig; cols = ceil(count_tracks/rows);); // if number of rows is less than Nbig
  vWidth = width / cols - border_w;
  vHeight = height / rows - border_h;
  aspect < (vHeight/vWidth) // if fitting to width
   ?      
   (xoffset = 0;
   vHeight = vWidth*aspect;)
   : // else fitting to height
    (vWidth = vHeight / aspect;
    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
      input_info(input_track(boss-1),prewidth,preheight);
      xpos_expand = (1-bossexpand)*(border_w + xpos);
      ypos_expand = (1-bossexpand)*(border_h + vHeight*(top_rows) + border_h*(top_rows) + ypos);
      vWidth_expand = (1-bossexpand)*(Nbig*vWidth+(Nbig-1)*border_w) + bossexpand*project_w;
      vHeight_expand = (1-bossexpand)*(Nbig*vHeight+(Nbig-1)*border_h) + bossexpand*project_h;
      crop == 1 ? //crop code
      (
       vWidth_expand/vHeight_expand<prewidth/preheight ? //crop from width
       (wsrc_expand = (preheight*(vWidth_expand/vHeight_expand));
        hsrc_expand = preheight;
        xsrc_expand = (prewidth - wsrc_expand)/2;
        ysrc_expand = 0;)
       : //else
        (wsrc_expand = prewidth;
        hsrc_expand = (prewidth*(vHeight_expand/vWidth_expand));
        xsrc_expand = 0;
        ysrc_expand = (preheight - hsrc_expand)/2;);
        )
        :
        (
        xsrc_expand = 0;ysrc_expand = 0;wsrc_expand = prewidth; hsrc_expand = preheight;
        );
     //plot code
     gfx_blit(
      input_track(boss-1), presasp,
      xpos_expand, ypos_expand, vWidth_expand, vHeight_expand,
      xsrc_expand,ysrc_expand,wsrc_expand,hsrc_expand
      );
 );
 bosscount = 0; // Counter for taking into account boss video
 loop(count_tracks + LeadDoubled, //main loop
  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 // last line
    : xpos = col*vWidth + border_w*col + xoffset // non-last line
    ;
   ((row>top_rows-1)&(col>left_cols-1)&(row<top_rows+Nbig)&(col<left_cols+Nbig))
   ? // if the grid number is part of big video
      bosscount = bosscount + 1 // increment counter
    : // else
    x-bosscount+1-LeadDoubled < Ntracks // if video exists
    ?
    (vidnum = x-bosscount+1;
      ((vidnum < boss) | (LeadDoubled)) ? vidnum = vidnum - 1;
     //crop code
     input_info(input_track(vidnum),prewidth,preheight);//get dimensions
     vxpos = border_w + xpos; //x position
     vypos = border_h + vHeight*(row) + border_h*(row) + ypos; //y position
     crop == 1 ? //crop code
     (
     vWidth/vHeight<prewidth/preheight ? //crop from width
      (wsrc = preheight*(vWidth/vHeight);//source width
       hsrc = preheight;//source height
       xsrc = (prewidth - wsrc)/2;//source x
       ysrc = 0;)//source y
      : //else
       (wsrc = prewidth;
       hsrc = prewidth*(vHeight/vWidth);
       xsrc = 0;
       ysrc = (preheight - hsrc)/2;);
       )
       :
       (xsrc = 0; ysrc = 0; wsrc = prewidth; hsrc = preheight);
      //plot code
      gfx_blit(
        input_track(vidnum), presasp,
        vxpos, vypos, vWidth, vHeight,
        xsrc,ysrc,wsrc,hsrc
        );
   );
  x += 1;
 );
 bossfront==1 //If the boss is in front plot
  ?
  (
   (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; // last line
        )
       : //else not the last line
        xpos = left_cols*vWidth + border_w*left_cols + xoffset; // non-last line
      //crop code
            input_info(input_track(boss-1),prewidth,preheight);
            xpos_expand = (1-bossexpand)*(border_w + xpos);
            ypos_expand = (1-bossexpand)*(border_h + vHeight*(top_rows) + border_h*(top_rows) + ypos);
            vWidth_expand = (1-bossexpand)*(Nbig*vWidth+(Nbig-1)*border_w) + bossexpand*project_w;
            vHeight_expand = (1-bossexpand)*(Nbig*vHeight+(Nbig-1)*border_h) + bossexpand*project_h;
            crop == 1 ? //crop code
             (
             vWidth_expand/vHeight_expand<prewidth/preheight ? //crop from width
             (wsrc_expand = (preheight*(vWidth_expand/vHeight_expand));
              hsrc_expand = preheight;
              xsrc_expand = (prewidth - wsrc_expand)/2;
              ysrc_expand = 0;)
             : //else
              (wsrc_expand = prewidth;
              hsrc_expand = (prewidth*(vHeight_expand/vWidth_expand));
              xsrc_expand = 0;
              ysrc_expand = (preheight - hsrc_expand)/2;);
              )
              :
              (
              xsrc_expand = 0; ysrc_expand = 0; wsrc_expand = prewidth; hsrc_expand = preheight;
              );
            gfx_blit(
               input_track(boss-1), presasp,
               xpos_expand, ypos_expand, vWidth_expand, vHeight_expand,
               xsrc_expand,ysrc_expand,wsrc_expand,hsrc_expand
            );
  );
);
jak352 is offline   Reply With Quote
Old Yesterday, 05:39 AM   #57
urednik
Human being with feelings
 
urednik's Avatar
 
Join Date: Apr 2010
Posts: 1,198
Default

Thanks Jonathan!

I saved both presets.
It might be the problem was my processor, but above 24 fps the video was flicking when grid with 20+ videos was showed.
Here is the outcome - hope you like it.

__________________
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.
urednik 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 07:10 AM.


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