Created
June 2, 2025 13:11
-
-
Save TwitchBronBron/4101039a2097cd15a0babb28fdaf3972 to your computer and use it in GitHub Desktop.
reaper crop - reaper video processing script for cropping a video to certain aspect ratios. Thanks to https://forums.cockos.com/showthread.php?t=295529
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SonicAxiom - crop video to aspect ratio | |
//@param1:wr 'width ratio' 16 1 70 35 1 | |
//@param2:hr 'height ratio' 9 1 70 35 1 | |
//@param3:wt 'horiz. center' 0 -4000 4000 0 2 | |
//@param4:ht 'vert. center' 0 -4000 4000 0 2 | |
//@param6:size 'text height' 0.06 0.015 0.07 0.035 0.005 | |
//@param8:txta 'show params' 0 0 1 0.5 1 | |
font="Verdana"; | |
input_info(0, sw, sh) ? ( | |
desired_aspect_ratio = wr / hr; | |
(sw / sh > desired_aspect_ratio) ? ( | |
ow = floor(sh * desired_aspect_ratio); | |
oh = sh; | |
) : ( | |
oh = floor(sw / desired_aspect_ratio); | |
ow = sw; | |
); | |
ow = (ow % 2 == 1) ? ow - 1 : ow; | |
oh = (oh % 2 == 1) ? oh - 1 : oh; | |
max_wt = floor(sw - ow); | |
max_ht = floor(sh - oh); | |
wt = wt > max_wt ? max_wt : wt < -max_wt ? -max_wt : wt; | |
ht = ht > max_ht ? max_ht : ht < -max_ht ? -max_ht : ht; | |
sx = floor((sw - ow - wt) / 2 + 0.5); | |
sy = floor((sh - oh - ht) / 2 + 0.5); | |
gfx_img_resize(-1, ow, oh); | |
gfx_blit(0, 0, 0, 0, ow, oh, sx, sy, ow, oh); | |
width_2k=floor(ow/3 + 0.5)*2; | |
height_2k=floor(oh/3 + 0.5)*2; | |
width_1080_1=floor(ow/2/2 + 0.5)*2; | |
height_1080=floor(oh/2/2 + 0.5)*2; | |
width_1080_2=floor(1080*desired_aspect_ratio/2 + 0.5)*2; | |
width_720=floor(720*desired_aspect_ratio/2 + 0.5)*2; | |
sprintf(#text,"AR: %d:%d | |
1:%f | |
%02dx%02d | |
%02dx%02d | |
%02dx%02d | |
%02dx%02d | |
%02dx%02d | |
",wr,hr,wr/hr, ow,oh,width_2k,height_2k,width_1080_1,height_1080,width_1080_2,1080,width_720,720); | |
gfx_setfont(size*sh,font); | |
strcmp(#text,"")==0 ? input_get_name(-1,#text); | |
gfx_str_measure(#text,txtw,txth); | |
yt = (sh- txth)*ypos; | |
gfx_set(255,0,0,txta); | |
gfx_str_draw(#text,(ow/2-txtw/2),oh/2-txth/2); | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment