05-22-2020, 08:13 AM | #1 |
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Script to crop video sides?
Does something like that exist? A script that can put black on both sides of the video and can move the image (horizontal offset) in the new box in the middle.
big pic
__________________
Most of my scripts can be found in ReaPack. If you find them useful, a donation would be greatly appreciated! Thank you! :) |
05-22-2020, 11:12 AM | #2 |
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
|
I had the need for a crop tool:
Code:
// Crop tool by M Fabian src=0; //@param1:x_coord 'x coord' 0 //@param2:y_coord 'y coord' 0 //@param3:width 'width' 1 //@param4:height 'height' 1 input_info(src,w,h) ? ( project_w=w; project_h=h; ); // preserve input dimensions gfx_dest = mybuf = gfx_img_resize(mybuf, project_w, project_h, 1); gfx_blit(src, 0, x_coord*project_w, y_coord*project_h, (width-x_coord)*project_w, (height-y_coord)*project_h, x_coord*project_w, y_coord*project_h, (width-x_coord)*project_w, (height-y_coord)*project_h); gfx_dest = -1; // main framebuffer gfx_blit(mybuf);
__________________
// MVHMF I never always did the right thing, but all I did wasn't wrong... |
05-22-2020, 12:41 PM | #3 |
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Thank you very much Fabian!!
__________________
Most of my scripts can be found in ReaPack. If you find them useful, a donation would be greatly appreciated! Thank you! :) |
05-22-2020, 01:18 PM | #4 |
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
I am trying to combine a simple code for moving the image with your code:
Code:
//@param1:xoffs 'X offset' 0 -1 1 0 0.01 //@param2:yoffs 'Y offset' 0 -1 1 0 0.01 //@param3:x_coord 'x coord' 0 //@param4:y_coord 'y coord' 0 input_info(0,w,h); gfx_blit(-1); x = xoffs*w; y = yoffs*h; gfx_blit(0,1, x,y); width = 1 - x_coord; height = 1 - y_coord; mybuf = gfx_img_resize(-1, w, h, 1); gfx_blit(0, 0, x_coord*w, y_coord*h, (width-x_coord)*w, (height-y_coord)*h, x_coord*w, y_coord*h, (width-x_coord)*w, (height-y_coord)*h); gfx_blit(mybuf);
__________________
Most of my scripts can be found in ReaPack. If you find them useful, a donation would be greatly appreciated! Thank you! :) Last edited by amagalma; 05-22-2020 at 01:57 PM. |
05-23-2020, 09:09 AM | #5 |
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
I have tried this too:
Code:
//@param1:x_pos 'Horiz Shift' 0 -1 1 0 0.01 //@param2:y_pos 'Vert Shift' 0 -1 1 0 0.01 //@param3:w_size 'Horizontal Curtains' 0 0 1 0.5 0.01 //@param4:h_size 'Vertical Curtains' 0 0 1 0.5 0.01 input_info(0, w, h); gfx_blit(0, 1, 0, 0, w, h, -x_pos*w, y_pos*h, w, h ); w_size != 0 ? ( w_size = w*w_size; gfx_fillrect(0,0,w_size,h); gfx_fillrect(w-w_size,0,w_size,h); ); h_size != 0 ? ( h_size = h*h_size; gfx_fillrect(0,0,w,h_size); gfx_fillrect(0,h-h_size,w,h_size); ); But it
__________________
Most of my scripts can be found in ReaPack. If you find them useful, a donation would be greatly appreciated! Thank you! :) Last edited by amagalma; 05-24-2020 at 03:00 AM. |
05-23-2020, 03:56 PM | #6 | |
Human being with feelings
Join Date: Jul 2011
Posts: 12
|
Quote:
Code:
//Overlay w/crop //@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 //@param9:cropL 'Crop left' 0 0 1 //@param10:cropR 'Crop right' 0 0 1 //@param11:cropT 'Crop top' 0 0 1 //@param12:cropB 'Crop bottom' 0 0 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); z = 10^(zoom/10); dw = (sw*z)|0; dh = (sh*z)|0; x = (project_w - dw + (project_w + dw)*xoffs)*.5; y = (project_h - dh + (project_h + dh)*yoffs)*.5; //gfx_img_resize(img2, dw*(1-cropL-cropR), dh*(1-cropT-cropB)); gfx_blit(img2,0, x+dw*cropL|0, y+dh*cropT|0, dw*(1-cropL-cropR), dh*(1-cropT-cropB), sw*cropL, sh*cropT, sw*(1-cropL-cropR), sh*(1-cropT-cropB)); ); ); |
|
05-24-2020, 01:05 AM | #7 | |
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Thanks! Although it does not move the image inside the black "curtains" on the sides. The code could be reduced down to this: Code:
//Crop/offset //@param1:xoffs 'X offset' 0 -1 1 0 //@param2:yoffs 'Y offset' 0 -1 1 0 //@param4:cropL 'Crop left' 0 0 1 //@param5:cropR 'Crop right' 0 0 1 //@param7:cropT 'Crop top' 0 0 1 //@param8:cropB 'Crop bottom' 0 0 1 input_info(0,sw,sh); gfx_blit(-1,0); x = (project_w - sw + (project_w + sw)*xoffs)*.5; y = (project_h - sh + (project_h + sh)*yoffs)*.5; gfx_blit(0,0, x+sw*cropL|0, y+sh*cropT|0, sw*(1-cropL-cropR), sh*(1-cropT-cropB), sw*cropL, sh*cropT, sw*(1-cropL-cropR), sh*(1-cropT-cropB));
__________________
Most of my scripts can be found in ReaPack. If you find them useful, a donation would be greatly appreciated! Thank you! :) Last edited by amagalma; 05-24-2020 at 01:21 AM. |
|
05-24-2020, 02:47 AM | #8 | |
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
And yet another variation: Code:
//@param1:x_pos 'Horiz Shift' 0 -1 1 0 0.01 //@param2:y_pos 'Vert Shift' 0 -1 1 0 0.01 //@param3:w_size 'Horizontal Curtains' 0 0 1 0.5 0.01 //@param4:h_size 'Vertical Curtains' 0 0 1 0.5 0.01 input_info(0, w, h); blank = -5000; gfx_blit(0, 1, 0, 0, w, h, -x_pos*w, y_pos*h, w, h ); w_size != 0 ? ( gfx_blit(blank, 0, 0, 0, w*w_size/2, h); gfx_blit(blank, 0, w-w*w_size/2, 0); ); h_size != 0 ? ( gfx_blit(blank, 0, 0, 0, w, h*h_size/2); gfx_blit(blank, 0, 0, h-h*h_size/2); );
__________________
Most of my scripts can be found in ReaPack. If you find them useful, a donation would be greatly appreciated! Thank you! :) Last edited by amagalma; 05-24-2020 at 03:00 AM. |
|
05-31-2020, 10:28 AM | #9 |
Human being with feelings
Join Date: Jul 2009
Posts: 7,571
|
while this does crop the image, it's not passing through any image/video on tracks below.
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
|
06-01-2020, 01:25 AM | #10 |
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
You mean being able to see the images below instead of black? Because I wanted it this way: to have black "curtains".
This will let the behind image to pass through: Code:
// Crop Image (let behind image through) //@param1:x_pos 'Horiz Shift' 0 -1 1 0 0.01 //@param2:y_pos 'Vert Shift' 0 -1 1 0 0.01 //@param3:w_size 'Horizontal Curtains' 0 0 1 0.5 0.01 //@param4:h_size 'Vertical Curtains' 0 0 1 0.5 0.01 input_info(0, w, h); other = 1; gfx_blit(0, 1, 0, 0, w, h, -x_pos*w, y_pos*h, w, h ); w_size != 0 ? ( w_amount = w*w_size/2; gfx_blit(other, 1, 0, 0,w_amount, h, 0, 0, w_amount, h ); gfx_blit(other, 1, w-w_amount, 0, w_amount, h, w-w_amount, 0, w_amount, h); ); h_size != 0 ? ( h_amount = h*h_size/2; gfx_blit(other, 1, 0, 0, w, h_amount, 0, 0, w, h_amount); gfx_blit(other, 1, 0, h-h_amount, w, h_amount, 0, h-h_amount, w, h_amount); ); Greatly optimized alternative: Code:
// Crop Image (optional let behind image through) //@param1:w_size 'Horizontal Crop' 0 0 1 0.5 0.01 //@param2:x_pos 'Fine tune x_pos' 0 -1 1 0 0.01 //@param4:h_size 'Vertical Crop' 0 0 1 0.5 0.01 //@param5:y_pos 'Fine tune y_pos' 0 -1 1 0 0.01 //@param7:back 'Let back image' 0 0 1 0.5 1 back = back == 0 ? -5000 : 1; gfx_blit(back); input_info(0, w, h); gfx_blit(0, 1, (w_size*w)/2, (h_size*h)/2, w - (w_size*w), h - (h_size*h), (w_size*w)/2 - x_pos*(w_size*w)/2, (h_size*h)/2 - y_pos*(h_size*h)/2, w - (w_size*w), h - (h_size*h) );
__________________
Most of my scripts can be found in ReaPack. If you find them useful, a donation would be greatly appreciated! Thank you! :) Last edited by amagalma; 06-02-2020 at 07:50 AM. |
06-01-2020, 08:39 AM | #11 |
Human being with feelings
Join Date: Jul 2009
Posts: 7,571
|
thanks for that. I wasn't actually requesting it, just pointing it out. A lot of people buy my video tools class just for the ability to crop.
You've done this in a different way than mine so I'll hang on to it. More people making video scripts is a very good thing for the community. Keep it up!
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
|
06-01-2020, 10:03 AM | #12 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Amazing.
Many thanks
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
06-02-2020, 07:56 AM | #13 | |
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
__________________
Most of my scripts can be found in ReaPack. If you find them useful, a donation would be greatly appreciated! Thank you! :) |
|
06-02-2020, 11:58 PM | #14 |
Human being with feelings
Join Date: May 2020
Location: Tokyo, JP
Posts: 4
|
I'm a tech idiot, so I just tried some simple and intuitive tools to edit videos. I found an ultimate review of video cropping software on google. If other newbies like me come across this thread, I hope this helps.
https://www.videoproc.com/video-edit...eo-cropper.htm |
07-17-2020, 05:30 AM | #15 | |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Quote:
Greetings ELi
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
|
07-25-2020, 08:01 PM | #16 |
Human being with feelings
Join Date: May 2017
Posts: 125
|
Great. I was looking for that.
Many thanks |
08-08-2022, 06:16 AM | #17 |
Human being with feelings
Join Date: Jan 2016
Location: Switzerland
Posts: 130
|
Just a quick question, is there a way to move the resulting cropped image to a different part of the screen? I tried using a 'Track opacity/zoom/pan' after this, but it doesn't seem to do what I'd like.
|
02-15-2023, 12:01 PM | #18 | |
Human being with feelings
Join Date: Apr 2017
Location: Scotland, UK
Posts: 56
|
Quote:
Code:
// Crop Image (optional let behind image through) //@param1:w_size 'Horizontal Crop' 0 0 1 0.5 0.01 //@param2:x_pos 'Fine tune x_pos' 0 -1 1 0 0.01 //@param4:h_size 'Vertical Crop' 0 0 1 0.5 0.01 //@param5:y_pos 'Fine tune y_pos' 0 -1 1 0 0.01 //@param7:back 'Let back image' 0 0 1 0.5 1 //@param9:x_pan 'x pan' 0 -1 1 0 0.01 //@param10:y_pan 'y pan' 0 -1 1 0 0.01 //@param11:zoom 'zoom' 1 0 2 1 0.01 back = back == 0 ? -5000 : 1; gfx_blit(back); input_info(0, w, h); gfx_blit(0, 1, -x_pan*w + (w_size*w)/2, -y_pan*h + (h_size*h)/2, zoom*(w - (w_size*w)), zoom*(h - (h_size*h)), (w_size*w)/2 - x_pos*(w_size*w)/2, (h_size*h)/2 - y_pos*(h_size*h)/2, w - (w_size*w), h - (h_size*h) ); Last edited by jak352; 02-15-2023 at 01:26 PM. |
|
02-16-2023, 07:13 AM | #19 | |
Human being with feelings
Join Date: Jan 2016
Location: Switzerland
Posts: 130
|
Quote:
Perhaps unrelated, but is there a standard way in video to do something like transparent background? For example, I can record on my webcam with background removal. However when I overlay this webcam video, the background is black. If I use something like Bandicam that records the webcam overlayed on the video, that black background is transparent. Is there a way to do that when overlaying images in Reaper? I figure it is something simple that I just can't figure out heh. |
|
02-16-2023, 07:54 AM | #20 | |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 679
|
Quote:
|
|
10-02-2023, 09:13 AM | #21 |
Human being with feelings
Join Date: Jul 2010
Location: San Francisco, CA
Posts: 250
|
much thanks for this. it's exactly what i needed. crop with controls for top bottom left and right and is an overlay for below video. along with a zoom and x/y offset i can control everything i need to for cropped video. much yay.
__________________
http://Windows 10, AMD Ryzen 5600X 3..., RTX 3060 12G |
Thread Tools | |
Display Modes | |
|
|