Old 11-26-2020, 10:32 PM   #1
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default Cropped Overlay

This might already exist, but I couldn't find it. It needs to be on its own track, then you use the overlay and background parameters to find the appropriate inputs, then you can crop the overlay and move it around on top of the background. It only lets you move to the edges of the project window. If you need to go beyond, crop more. I tried to add like zoom/scaling, but that got weird, so probably just use a different preset on the individual input tracks for that.



Code:
// ashcat_lt cropped overlay
//@param 1:in1 'overlay (-1=next video track)' -1 -1 50 0 1
//@param 2:in2 'background (-1=second next)' -1 -1 50 0 1
//@param 3:source_L 'source Left edge' 0 0 1 0.5
//@param 4:source_R 'source Right edge' 1 0 1 0.5
//@param 5:source_T 'source Top edge' 0 0 1 0.5
//@param 6:source_B 'source Bottom edge' 1 0 1 0.5
//@param 7:xoffs_d 'destination X offset (right)' 0 -1 1 0
//@param 8:yoffs_d 'destination Y offset (down)' 0 -1 1 0



in1 = in1== -1? input_track(0): in1;
in2 = in2== -1 ? input_track(1): in2;


source_x1 = source_L * project_w;
source_x2 = max(source_x1, source_R * project_w);
source_w = source_x2 - source_x1;
R_pad = project_w - source_x2;
dest_x = xoffs_d <= 0 ? source_x1 * (1 + xoffs_d) : source_x1 + (R_pad * xoffs_d); 

source_y1 = source_T * project_h;
source_y2 = max(source_y1, source_B * project_h);
source_h = source_y2 - source_y1;
B_pad = project_h - source_y2;
dest_y = yoffs_d <= 0 ?  source_y1 * (1 + yoffs_d) : source_y1 + (B_pad * yoffs_d); 



oldCS=colorspace;
colorspace='YV12';
gfx_set (0,0,0,1,0,-1);
gfx_fillrect (0,0,project_w,project_h);

temp = gfx_img_resize (temp,project_w,project_h);
gfx_dest = temp;
gfx_blit (in2);

gfx_blit (in1,0,dest_x,dest_y,source_w,source_h,source_x1,source_y1,source_w,source_h);




gfx_dest = -1;

gfx_blit(temp);

colorspace=oldCS;
ashcat_lt is online now   Reply With Quote
Old 03-30-2021, 10:01 AM   #2
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Nice one! You can add it here: https://forum.cockos.com/showthread.php?t=213832
vitalker is offline   Reply With Quote
Old 09-22-2021, 10:51 AM   #3
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

I'm not sure how much of an improvement this makes, but it will allow you to zoom and resize the cropped overlay image without having to use another video processor. It's kind of up to you to maintain the aspect ratios, though.

I also added a couple of blend modes to make it a little more useful on its own. I may go through and add the rest at some point, but these three are the ones I'm most likely to use, so...

Code:
// ashcat_lt better cropped overlay
//@param 1:in1 'overlay (-1=next video track)' -1 -1 50 0 1
//@param 2:in2 'background (-1=second next)' -1 -1 50 0 1
//@param 3:source_L 'source Left edge' 0 0 1 0.5
//@param 4:source_R 'source Right edge' 1 0 1 0.5
//@param 5:source_T 'source Top edge' 0 0 1 0.5
//@param 6:source_B 'source Bottom edge' 1 0 1 0.5
//@param 7:dest_L 'destination Left edge' 0 0 1 0.5
//@param 8:dest_R 'destination Right edge' 1 0 1 0.5
//@param 9:dest_T 'destination Top edge' 0 0 1 0.5
//@param 10:dest_B 'destination Bottom edge' 1 0 1 0.5
//@param 11:mode 'blend mode (normal, add, difference' 0 0 2 0 1


in1 = in1== -1? input_track(0): in1;
in2 = in2== -1 ? input_track(1): in2;


source_x1 = source_L * project_w;
source_x2 = max(source_x1, source_R * project_w);
source_w = source_x2 - source_x1;
dest_x1 = dest_L * project_w;
dest_x2 = max(dest_x1, dest_R * project_w);
dest_w = dest_x2 - dest_x1;

source_y1 = source_T * project_h;
source_y2 = max(source_y1, source_B * project_h);
source_h = source_y2 - source_y1;
dest_y1 = dest_T * project_h;
dest_y2 = max(dest_y1, dest_B * project_h);
dest_h = dest_y2 - dest_y1;

mode == 2 ? mode = 19;


oldCS=colorspace;
colorspace='YV12';
gfx_set (0,0,0,1,0,-1);
gfx_fillrect (0,0,project_w,project_h);

temp = gfx_img_resize (temp,project_w,project_h);
gfx_dest = temp;
gfx_blit (in2);
gfx_mode = mode;
gfx_blit (in1,0,dest_x1,dest_y1,dest_w,dest_h,source_x1,source_y1,source_w,source_h);

gfx_mode = 0;


gfx_dest = -1;

gfx_blit(temp);

colorspace=oldCS;
ashcat_lt is online now   Reply With Quote
Old 09-22-2021, 04:17 PM   #4
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

I can't remember either where I found the overlay with crop I was using until a couple of weeks ago. I am currently cooking a very elaborate version of this preset that would allow cropping/zooming (with auto re-centering) along with rotation, framing and pseudo-3d projections. Unfortunately it's not ready for prime time yet and with my production schedule coming up I don't expect to finish before the end of next month.

The unique feature of yours is the various blend modes...something to think about :-)

p.s. BTW I have not looked at your code in details but I think you don't even need the temporary image as gfx_blit() can directly copy/truncate/zoom/offset the source image into the frame buffer. You might also want to look at the test preset I made in this thread: https://forum.cockos.com/showthread.php?t=255401
papagirafe is online now   Reply With Quote
Old 09-22-2021, 05:42 PM   #5
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

Thanks for looking. Yeah, I probably don’t need the temp buffer, but I just kind of prefer to do my manipulations “off screen” until the end. Most of my presets overwrite the main buffer with a black rectangle at the very beginning, does processing and manipulations in off screen buffers, and then blit to the essentially blank main buffer at the end. Might be losing some efficiency that way, but some of the things I’ve done kind of require it, and it just feels safer somehow.
ashcat_lt is online now   Reply With Quote
Old 01-10-2022, 12:53 AM   #6
bd32
Human being with feelings
 
Join Date: Jun 2012
Posts: 362
Default Zoom controls are good but do I need another FX for crop?

I don't know anything about the technical side of how you made this but I've just been trying to use this FX to take a video and mainly get stuff to the sides out of the picture but also a bit of the height as well. I still get too much on the side but not enough on the top so I feel like I need to crop as well. I don't mind if the aspect ratio is a bit off. I've attached what I've been using. If I just use the crop FX the picture is too small. I'd like it to fill the screen more so I've been using this FX. Thanks.
Attached Images
File Type: jpg Track opacity,zoom,pan fx Reaper.jpg (50.3 KB, 148 views)
bd32 is offline   Reply With Quote
Old 01-14-2022, 06:04 AM   #7
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

hi

using ashcats script

dial in some destination_L and some destination_T
this shows the image/video select with the overlay (first knob)


using the basic helper script
dial in a negativ zoom
and dial in x and y offset f.i. zoom -0.9 x 0.1 y 0.1


with ashcat's code you have more options via the blending modes.

greetz

TIP: Hold CTRL while dialing the knobs (drag or with mousewheel makes more fun here)

Last edited by bobobo; 01-14-2022 at 07:35 AM.
bobobo is offline   Reply With Quote
Old 01-14-2022, 07:00 PM   #8
bd32
Human being with feelings
 
Join Date: Jun 2012
Posts: 362
Default

Quote:
Originally Posted by bobobo View Post
hi

using ashcats script

dial in some destination_L and some destination_T
this shows the image/video select with the overlay (first knob)


using the basic helper script
dial in a negativ zoom
and dial in x and y offset f.i. zoom -0.9 x 0.1 y 0.1


with ashcat's code you have more options via the blending modes.

greetz

TIP: Hold CTRL while dialing the knobs (drag or with mousewheel makes more fun here)
Looking forward to trying this out soon. I'm not sure what ashcats script is. It/s not the one I'm using is it? Thanks!

Last edited by bd32; 01-14-2022 at 08:03 PM.
bd32 is offline   Reply With Quote
Old 01-15-2022, 09:22 AM   #9
bobobo
Human being with feelings
 
bobobo's Avatar
 
Join Date: Oct 2014
Posts: 1,356
Default

ashcat_it' s script is above
or here https://forum.cockos.com/showpost.ph...13&postcount=3

i posted tips using the basic helper too

greetz

Last edited by bobobo; 01-15-2022 at 11:06 PM.
bobobo is offline   Reply With Quote
Old 01-15-2022, 04:09 PM   #10
bd32
Human being with feelings
 
Join Date: Jun 2012
Posts: 362
Default

Quote:
Originally Posted by bobobo View Post
ashcart_it' s script is above
or here https://forum.cockos.com/showpost.ph...13&postcount=3

i posted tips using the basic helper too

greetz
OK. Thanks. I'm going to check that out.
bd32 is offline   Reply With Quote
Old 01-17-2022, 01:55 PM   #11
bd32
Human being with feelings
 
Join Date: Jun 2012
Posts: 362
Default

Quote:
Originally Posted by bd32 View Post
OK. Thanks. I'm going to check that out.
At first I put in the Ashcat script and hit ctrl/s and all the video disappeared but eventually figured out adjusting the overlay control got it back.I'm making some progress. I'm going to start a new topic asking if it's possible to tilt a video as I've got kind of an extreme camera angle. https://forum.cockos.com/showthread....73#post2517273 Thanks!

Last edited by bd32; 01-17-2022 at 02:03 PM.
bd32 is offline   Reply With Quote
Old 01-17-2022, 02:07 PM   #12
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

The stock Track Opacity/Zoom/Pan preset includes rotation, if that helps. Put that on the source track, or if you've already got it there for the zoom/pan part, just turn that other knob.

Edit - but looking at your other post, I think you're trying to sort of change the perspective, which is a different thing. It definitely is possible, but I don't know off the top of my head of a preset which does it.
ashcat_lt is online now   Reply With Quote
Old 01-17-2022, 02:19 PM   #13
bd32
Human being with feelings
 
Join Date: Jun 2012
Posts: 362
Default

Quote:
Originally Posted by ashcat_lt View Post
The stock Track Opacity/Zoom/Pan preset includes rotation, if that helps. Put that on the source track, or if you've already got it there for the zoom/pan part, just turn that other knob.

Edit - but looking at your other post, I think you're trying to sort of change the perspective, which is a different thing. It definitely is possible, but I don't know off the top of my head of a preset which does it.
As an example I found a youtube video. Most of it doesn't apply but from 1:16 to 1:18 it shows. https://youtu.be/Dq3YC70W7UY?t=72
Of course what they're doing is very different in that I guess they have many camera angles and I've just got my one. But still, with some liberties with aspect ratio I'd have a better viewing angle. Thanks!
bd32 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 11:53 AM.


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