Log in

View Full Version : Script optimization


Serranya
6th October 2012, 23:41
Hello,
i have a clip with a 4:3 DAR, and want it to change to 19:9 for YouTube.

Since i dont want to deform my clip, i add fancy Borders to the left and the right to the clip like this:
http://i.imgur.com/UuW1S.jpg

here is my script:

function RealtimeBorderResize(clip src, int targetBorderWidth, int targetHeight)
{
copy = src
newWidth = Width(src) * targetHeight / Height(src)

copy = BicubicResize(copy,newWidth,targetHeight)
resized = copy

borderWidth = (targetWidth - Width(resized)) / 2

copy = AddBorders(copy, borderWidth,0,borderWidth,0)

leftBorder = Crop(resized,0,0,borderWidth,0)
rightBorder = Crop(resized,newWidth-borderWidth,0,0,0)

copy = Overlay(copy,leftBorder,0,0)
copy = Overlay(copy,rightBorder,targetWidth-borderWidth,0)

return copy


I want to ask, if you know any way, to optimize this code
in order to let the script run faster.

regarts Serra

IanB
7th October 2012, 01:32
function RealtimeBorderResize(clip src, int targetWidth, int targetHeight)
{
newWidth = Width(src) * targetHeight / Height(src)

resized = BicubicResize(src, newWidth,targetHeight)

borderWidth = (targetWidth - Width(resized)) / 2

leftBorder = Crop(resized, 0,0,borderWidth,0)
rightBorder = Crop(resized, newWidth-borderWidth,0,0,0)

# leftBorder = Blur(leftBorder, 1.0) # The .jpg was blurred
# rightBorder = Blur(rightBorder, 1.0)

leftBorder = Levels(leftBorder, 0,1.0,128, 0,255) # Maybe 64,1.0,192, 0,255 would look better
rightBorder = Levels(rightBorder, 0,1.0,128, 0,255)

return StackHorizontal(leftBorder, resized, rightBorder)
}