Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th October 2012, 23:41   #1  |  Link
Serranya
Registered User
 
Join Date: Sep 2011
Posts: 1
Script optimization

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:
Code:
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
Serranya is offline   Reply With Quote
Old 7th October 2012, 01:32   #2  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Code:
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)
}
IanB is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 +1. The time now is 21:09.


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