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

Reply
 
Thread Tools Display Modes
Old 01-06-2022, 04:17 PM   #1
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default new "item opacity/zoom/pan/stretch" preset

Here is my new year's gift!



This preset replaces advantageously the "Basic helper: track opacity zoom pan" in most situations. Among the new features:
- automatic pre-scaling by maximizing width or height to project dimensions
- Geometry correction by stretching/compressing corners
- uses item's fade in/out if alpha is set to negative value.
- more precise rotation with ajustable center coordinates.
- image corrections are done before scaling for maximum precision

I haven't testing under all possible conditions so feedback is welcomed. For full features you need to set the project video dimensions.

**update 01/08: rotation code bypassed if angle=0**
Code:
//item opacity/zoom/pan/stretch v2
//by papagirafe
//@param alpha 'alpha' 1 -0.01 1 .5 .01
//@param maxh 'maximize w/h' 0 0 1 0.5 1
//@param zoom 'zoom' 1 0.01 4 1 0.01
//@param offX 'offset x' 0 -1 1 0 0.001
//@param offY 'offset y' 0 -1 1 0 0.001
//@param filter 'smoothing' 1 0 1 .5 1
//@param use_srca 'alpha channel' 1 0 1 0.5 1

//pre-rotation before corners stretching
//@param9:rota "pre-rotation" 0 -180 180 0 0.1
//@param cxo "center off x" 0 -1 1 0 0.001 
//@param cyo "center off y" 0 -1 1 0 0.001

// corners stretching
//@param13:tloX "top left x" 0 -2 2 0 0.001
//@param tloY "top left y" 0 -2 2 0 0.001
//@param troX "top right x" 0 -2 2 0 0.001
//@param troY "top right y" 0 -2 2 0 0.001
//@param bloX "bottom left x" 0 -2 2 0 0.001
//@param bloY "bottom left y" 0 -2 2 0 0.001
//@param broX "bottom right x" 0 -2 2 0 0.001
//@param broY "bottom right y" 0 -2 2 0 0.001

function xy2polar(x,y,r*,phi*)
(
  r=sqrt(x^2+y^2);
  phi=2*atan(y/(x+r));
);
function polar2xy(r,phi,x*,y*)
(
  x=r*cos(phi);
  y=r*sin(phi);
);


function rotate_coord(tx,ty) instance(x,y,r,phi) local(cx,cy) global(xft,sw,sh,cxo,cyo,rota)
(
  //coordonnées du centre de rotation
  cx=(sw+cxo*sw)/2;  
  cy=(sh+cyo*sh)/2;

  xy2polar(xft[tx]-cx,xft[ty]-cy,r,phi);
  phi-=rota;
  polar2xy(r,phi,x,y);
  xft[tx]=x+cx; xft[ty]=y+cy;
);

// initialisation de l'environnement graphique
input_info(0,sw,sh,0,wet);  
alpha=alpha<0?wet:alpha;    // negative alpha = "wet"
!project_wh_valid ?  (project_w = sw; project_h=sh;); 
use_srca && input_track(0) != 0 ? colorspace='RGBA';
tlx=0;tly=1;trx=2;try=3;blx=4;bly=5;brx=6;bry=7;  // code clarity
filter*=0x100; use_srca*=0x10000; 
sx=0; 
sy=0;
rota=rota/180*$pi;
zoom*=(maxh?project_h/sh:project_w/sw);

dx=floor(project_w/2 - sw*zoom/2 + offX*project_w -1);
dy=floor(project_h/2 - sh*zoom/2 + offY*project_h -1);
dw=floor(sw*zoom);
dh=floor(sh*zoom);
 
gfx_blit(input_track(0),1);   

// initialisation de la matrice de déformation
xft[tlx]=-tloX*sw;    xft[tly]=-tloY*sh;
xft[trx]=sw-troX*sw;  xft[try]=-troY*sh;
xft[blx]=-bloX*sw;    xft[bly]=sh-bloY*sh;
xft[brx]=sw-broX*sw;  xft[bry]=sh-broY*sh;

rota!=0?(
  rotate_coord(tlx,tly);
  rotate_coord(trx,try);
  rotate_coord(blx,bly);
  rotate_coord(brx,bry);
);

img=gfx_img_alloc(sw,sh,1); 
gfx_set(1,1,1,1,filter,img);
gfx_xformblit(0,0,0,sw,sh,2,2,xft);

gfx_set(1,1,1,alpha,filter|use_srca,-1 );
gfx_blit(img,1,dx,dy,dw,dh,sx,sy,sw,sh);
gfx_img_free(img);

Last edited by papagirafe; 01-08-2022 at 04:36 AM. Reason: minor code update
papagirafe is offline   Reply With Quote
Old 01-07-2022, 07:34 AM   #2
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Nice one. Now it is possible to hide something on the video.
vitalker is offline   Reply With Quote
Old 01-07-2022, 09:16 AM   #3
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by vitalker View Post
Nice one. Now it is possible to hide something on the video.
You can definitely use this preset to stretch a face beyond recognition
papagirafe is offline   Reply With Quote
Old 10-18-2022, 04:42 PM   #4
hans
Human being with feelings
 
Join Date: Aug 2020
Posts: 276
Default

Nice! I think i'm going to use this one!

Just started with simple video editing for basic stuff with Reaper. So freeaking nice to do automation and stuff the DAW way!
hans 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 01:46 AM.


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