|
11-26-2020, 10:32 PM | #1 |
Human being with feelings
Join Date: Dec 2012
Posts: 7,294
|
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;
__________________
Lorenzo's Tractor is Everywhere --- Ash's Tube --- Join the Partnership for a Drum Free Amerika |
03-30-2021, 10:01 AM | #2 |
Human being with feelings
Join Date: Dec 2012
Posts: 13,334
|
Nice one! You can add it here: https://forum.cockos.com/showthread.php?t=213832
|
09-22-2021, 10:51 AM | #3 |
Human being with feelings
Join Date: Dec 2012
Posts: 7,294
|
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;
__________________
Lorenzo's Tractor is Everywhere --- Ash's Tube --- Join the Partnership for a Drum Free Amerika |
09-22-2021, 04:17 PM | #4 |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 690
|
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 |
09-22-2021, 05:42 PM | #5 |
Human being with feelings
Join Date: Dec 2012
Posts: 7,294
|
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.
__________________
Lorenzo's Tractor is Everywhere --- Ash's Tube --- Join the Partnership for a Drum Free Amerika |
01-10-2022, 12:53 AM | #6 |
Human being with feelings
Join Date: Jun 2012
Posts: 362
|
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.
|
Thread Tools | |
Display Modes | |
|
|