03-27-2021, 12:41 PM | #1 |
Human being with feelings
Join Date: Feb 2017
Location: London
Posts: 26
|
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. |
03-27-2021, 01:08 PM | #2 |
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Noice! You can add it here: https://forum.cockos.com/showthread.php?t=213832
|
03-30-2021, 09:51 AM | #3 |
Human being with feelings
Join Date: Dec 2012
Posts: 7,272
|
Sounds a whole lot like what I did here, but I guess I’m not invited to the big thread.
https://forum.cockos.com/showthread.php?t=245490
__________________
Lorenzo's Tractor is Everywhere --- Ash's Tube --- Join the Partnership for a Drum Free Amerika |
03-30-2021, 10:00 AM | #4 | |
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
|
|
03-30-2021, 10:04 AM | #5 |
Human being with feelings
Join Date: Dec 2012
Posts: 7,272
|
I was kinda just playing, but honestly that “without video” thing is kind of annoying. It’s come up a couple of times now, and on things that I feel are pretty straightforward and easy to understand from my text descriptions. I made these things so that I can make other videos, and I share them with y’all thinking that might help or at least inspire, but then they get ignored because I didn’t bother to make a video out of me making a video out of...
__________________
Lorenzo's Tractor is Everywhere --- Ash's Tube --- Join the Partnership for a Drum Free Amerika |
03-30-2021, 10:18 AM | #6 | |
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
|
|
03-30-2021, 10:25 AM | #7 |
Human being with feelings
Join Date: Dec 2012
Posts: 7,272
|
Seriously no hard feelings! I really could have just asked or posted in the big thread anyway...
__________________
Lorenzo's Tractor is Everywhere --- Ash's Tube --- Join the Partnership for a Drum Free Amerika |
03-30-2021, 11:17 AM | #8 |
Human being with feelings
Join Date: Aug 2019
Posts: 6
|
They say it's like buses... you wait and wait, then three come along at once. I was desperate for one of these a month or so back and hacked up my own from half-understanding various other bits of code, which I've been meaning to post for a while. I don't think mine trims quite as elegantly as these, but the scaling does work. I have it set so that the opacity is controlled by track zoom, because that's what I usually want. I'm using it to make split-screen solo cover videos with parts fading in and out as they occur.
I will post it when I get it tidied up. |
03-30-2021, 11:36 AM | #9 |
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Sure. More presets, more fun!
|
06-01-2021, 03:11 PM | #10 | |
Human being with feelings
Join Date: Aug 2010
Posts: 396
|
Quote:
The only thing I'm noticing is that the 'zoom' doesn't seem to do anything? I'm hoping there's a way to have the 'zoom' only affect the video that this effect is on. With the default 'image overlay' preset, the 'zoom' will zoom any/all visible video. FWIW, I'm on OSX Mojave, Reaper v6.29 EDIT: Nevermind. I got it working Last edited by benmrx; 06-04-2021 at 08:55 AM. |
|
10-30-2021, 04:14 AM | #11 |
Human being with feelings
Join Date: Jan 2011
Posts: 1,167
|
|
10-31-2021, 01:21 PM | #12 |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 679
|
Hi all!
I was planning to post a very elaborate version of this preset in the coming weeks but since there is a tremendous interest, I am releasing an early version that already support cropping, zoom and adding a basic frame. The values are proportional to the project resolution. You will also notice that cropping allows a negative value of -0.001 that allows you to link copping parameters together. Beware that gradient type frames will not work well with multiple semi-transparent video layers. edit (2021-nov-9): corrected uninitialized variable bug in frame functions Code:
//Overlay: Image v2.0 w/crop/frames //by papagirafe //@param1:alpha 'alpha' 1 0 1 .5 .01 //@param2:zoom 'zoom' 1 0.01 4 1 0.01 //@param3:offX 'offset x' 0 -1 1 0 0.001 //@param4:offY 'offset y' 0 -1 1 0 0.001 //@param5:cropL 'crop L' 0 0 1 0.5 0.001 //@param6:cropR 'crop R' 0 -0.001 1 0.5 0.001 //@param7:cropT 'crop T' 0 -0.001 1 0.5 0.001 //@param8:cropB 'crop B' 0 -0.001 1 0.5 0.001 //@param10:frame 'frame' 0 0 1 0.5 0.001 //@param11:frameType 'type' 0 0 2 1 1 //@param12:br 'r' 1 0 1 0.5 0.01 //@param13:bg 'g' 1 0 1 0.5 0.01 //@param14:bb 'b' 1 0 1 0.5 0.01 //@param15:ba 'a' 1 0 1 0.5 0.01 //@param17:filter 'filter' 1 0 1 .5 1 //@param18:use_srca 'alpha channel' 1 0 1 0.5 1 // cadre externe couleur pleine function frame_solid() local(i) ( loop(frame,gfx_gradrect(dx-i,dy-i,dw+2*i,1, br,bg,bb,ba, 0,0,0,0, 0,0,0,0 );i=(i+1)%frame;); loop(frame,gfx_gradrect(dx-i,dy+dh+i,dw+2*i,1, br,bg,bb,ba, 0,0,0,0, 0,0,0,0 );i=(i+1)%frame;); loop(frame,gfx_gradrect(dx-i,dy-i+1, 1, dh+2*i-1, br,bg,bb,ba, 0,0,0,0, 0,0,0,0 );i=(i+1)%frame;); loop(frame,gfx_gradrect(dx+dw+i,dy-i,1,dh+2*i+1, br,bg,bb,ba, 0,0,0,0, 0,0,0,0 );i=(i+1)%frame;); ); // cadre externe de couleur à gradient alpha function frame_gradient() local(i) ( loop(frame,gfx_gradrect(dx-i,dy-i,dw+2*i,1, br,bg,bb,ba-i*delta, 0,0,0,0, 0,0,0,0 );i=(i+1)%frame;); loop(frame,gfx_gradrect(dx-i,dy+dh+i,dw+2*i,1, br,bg,bb,ba-i*delta, 0,0,0,0, 0,0,0,0 );i=(i+1)%frame;); loop(frame,gfx_gradrect(dx-i,dy-i+1, 1, dh+2*i-1, br,bg,bb,ba-i*delta, 0,0,0,0, 0,0,0,0 );i=(i+1)%frame;); loop(frame,gfx_gradrect(dx+dw+i,dy-i,1,dh+2*i+1, br,bg,bb,ba-i*delta, 0,0,0,0, 0,0,0,0 );i=(i+1)%frame;); ); // cadre interne à gradient alpha function frame_gradient2() local(i) ( gfx_set(0,0,0,1,0x100); src=input_track(0); loop(frame,gfx_a = ba-i*delta; gfx_blit(src,0,dx+i,dy+i,dw-2*i,1,dx+i,dy+i,dw-2*i,1); i=(i+1)%frame;); loop(frame,gfx_a = ba-i*delta; gfx_blit(src,0,dx+i,dy+dh-i,dw-2*i,1,dx+i,dy+dh-i,dw-2*i,1);i=(i+1)%frame;); loop(frame,gfx_a = ba-i*delta; gfx_blit(src,0,dx+i,dy+i,1,dh-2*i,dx+i,dy+i,1,dh-2*i);i=(i+1)%frame;); loop(frame,gfx_a = ba-i*delta; gfx_blit(src,0,dx+dw-i,dy+i,1,dh-2*i+1, dx+dw-i,dy+i+2,1,dh-2*i+1);i=(i+1)%frame;); ); // initialisation de l'environnement graphique input_info(0,sw,sh); //dimensions de la source avant découpage !project_wh_valid ? (project_w = sw; project_h=sh;); // dimensions non définie, on prend alors la source use_srca && input_track(0) != 0 ? colorspace='RGBA'; mode=(filter>0?0x100:0) | (use_srca?0x10000:0); //calculs du découpage en pixels selon zoom et source cropL=floor(cropL*sw); cropR=cropR<0 ? cropL : floor(cropR*sw); // paramètre négatif lie à celle de gauche cropT=cropT<0 ? cropL : floor(cropT*sw); // paramètre négatif lie à celle de gauche cropB=cropB<0 ? cropT : floor(cropB*sw); // paramètre négatif lie à celle du haut // coordonnées et dimensions de la source après découpage sx=cropL; sy=cropT; sw-=(cropL+cropR); sw<1?sw=1; sh-=(cropT+cropB); sh<1?sh=1; // compensations du zoom en fonction des dimensions relative (et coupées) de la source par rapport au projet zoom*=min(project_w/sw,project_h/sh); /* calcul des coordonnées et des dimensions à la destination */ dx=floor(project_w/2 - sw*zoom/2 + offX*project_w); dy=floor(project_h/2 - sh*zoom/2 + offY*project_h); dw=floor(sw*zoom); dh=floor(sh*zoom); frame=ceil(min(dw,dh)*frame); /* affichage des couches inférieures */ gfx_blit(input_track(0),1); //si la couche 1 n'existe pas alors on obtient du noir et c'est ce qu'on veut! /* affichage de l'image traitée*/ gfx_set(1,1,1,alpha,mode,-1); gfx_blit(0,1,dx,dy,dw,dh,sx,sy,sw,sh); /* dessin des bordures selon le type */ delta = ba / frame; frame > 0 ? ( frameType==0 ? frame_solid() : ( frameType==1 ? frame_gradient() : ( frameType==2 ? frame_gradient2() ))); Last edited by papagirafe; 11-09-2021 at 05:58 AM. |
Thread Tools | |
Display Modes | |
|
|