View Single Post
Old 03-27-2021, 12:41 PM   #1
SawdustAndDiamonds
Human being with feelings
 
SawdustAndDiamonds's Avatar
 
Join Date: Feb 2017
Location: London
Posts: 26
Default Tweaked overlay preset to add l/r/t/b controls

Here's a tweaked version of the 'image overlay' preset. This allows you to overlay a chosen rectangle from within a video, instead of always overlaying the entire video.

Code:
//Image overlay with l/r/t/b controls
//@param1:opacity 'opacity' 1
//@param2:zoom 'zoom' 0 -15 15 0
//@param3:xoffs 'X offset' 0 -1 1 0
//@param4:yoffs 'Y offset' 0 -1 1 0
//@param6:filter 'filter' 0 0 1 0.5 1
//@param7:use_srca 'alpha channel' 1 0 1 0.5 1
//@param8:LeftEdge 'Left edge' 0 0 1920 200 1
//@param9:RightEdge 'Right edge' 1920 0 1920 200 1
//@param10:TopEdge 'Top edge' 0 0 1080 200 1
//@param11:BottomEdge 'Bottom edge' 1080 0 1080 200 1

img1=input_track(0);
img2=0;
use_srca && img2 != img1 ? colorspace='RGBA';
input_info(img1,img1w,img1h) && project_wh_valid===0 ?  ( project_w = img1w; project_h = img1h; );

a = opacity < 0.01 ? 0 : opacity > 0.99 ? 1 : opacity;

img2 != img1 && input_info(img2,sw,sh) ? (
  gfx_blit(img1,0);
  a>0?(
    gfx_a=a;
    gfx_mode = (filter>0.5 ? 256 : 0)|(use_srca?0x10000:0);
    gfx_blit(frame_0,1,LeftEdge+xoffs*project_w,TopEdge+yoffs*project_h,min(project_w, RightEdge-LeftEdge), min(project_h, BottomEdge-TopEdge), LeftEdge,TopEdge,min(project_w, RightEdge-LeftEdge),  min(project_h, BottomEdge-TopEdge));
  );
);

Notes:
- As usual, you can Ctrl+Click for tiny adjustments, to set the edges to the exact pixel you want.
- Controls for LeftEdge etc are in pixels. If you want to use a resolution larger than 1920x1080, you'll need to edit the code.
- Once you've used the edge controls to select your rectangle, you can use X/Y offset to move the overlay around. This will move the overlaying video, while keeping the same rectangle of your video to overlay.
- The zoom control doesn't work. But you can just put another instance of video processor before it in the FX chain, and use the zoom preset on there.

You can see the code in action at 0:43 in this video:


Edit: Adding GIF
__________________
Experimental dreampop with hundreds of layers, as Callum Martin-Moore on Spotify, Bandcamp, Facebook, Linktree!

Last edited by SawdustAndDiamonds; 03-27-2021 at 01:52 PM.
SawdustAndDiamonds is offline   Reply With Quote