Notifications
Clear all

[Closed] letterbox script

I’m writing a script to add letterbox bars to top and bottom of viewport. Am having trouble with finding correct formula to viewport size transfer from render size. Have found formula here for reference ( http://fxguide.com/forums/showthread.php?p=19664 ). Another problem is finding way to adjust for margin added with Safe frame to sides or top; depending on whether render image aspect is greater than viewport aspect ratio.

Here is part of what I have so far:


 
 global posX = gw.getWinSizeX() as float
 global posY = gw.getWinSizeY() as float
 	
 	
 	global imageAspect = getRendImageAspect()
 	
 	global viewAspect = (posX as float) / (posY as float)
 	
 	global PosWide = 1 
 	
 global prop1 = (posX/renderWidth)
 global prop2 = (posY/renderHeight)	
 	
 	global matteValuer = 2.35-- theRollout.CamDatabase_spinner_Matting.value
 	
 	
 temp1 =	(posY/matteValuer ) /2 --* 1.85
 temp2 =	(renderWidth/matteValuer ) --/2 --* 1.85
 
 
 
 
 global temp3 = (renderHeight - temp2) /2 
 
 
 
 	
 --	if imageAspect > viewAspect then PosWide = 33 --66 --margin_topbottom (changes proportion)
 		
 	
 --	if imageAspect < viewAspect then PosWide = 48 --margin_sides (doesnt change)
 
 	-- 43 --1.78 (4:3) (if posY = 349)
 	-- 50 --1.85 (4:3) (if posY = 349)
 	-- 76 --2.35 (4:3) (if posY = 349)
 	
 	-- 60 --1.78 (16:9) (if posY = 349)
 	-- 66 --1.85 (16:9) (if posY = 349)
 	-- 88 --2.35 (16:9) (if posY = 349)
 	
 
 
 global PosWide =  temp3 
 
 
 gw.hPolyline #([0,PosWide ,0], [posX ,PosWide ,0]) true rgb:#([255,0,0],[255,0,0])
 
 
 gw.hPolyline #([0,(posY-PosWide) ,0], [posX,(posY-PosWide),0]) true rgb:#([255,0,0],[255,0,0])
 
 
 gw.enlargeUpdateRect #whole 
 
 gw.updateScreen()
 
 
 
 

On another note; can’t figure out how to apply colorpicker value to rgb value for polyline. Have done this with viewport text but not polyline.

3 Replies

Still having trouble with figuring this out. Have managed to find how to calculate top margins to line up with top of frame but still can’t find where lines go for letterbox crop. Here is what I have now.




global posX = gw.getWinSizeX() as float
global posY = gw.getWinSizeY() as float
	
	
	global imageAspect = getRendImageAspect()
	
	global viewAspect = (posX as float) / (posY as float)
	
	global PosWide = 1 
	
	 
global prop1 = (posX/renderWidth)
global prop2 = (posY/renderHeight)	


aspect = viewAspect / imageAspect


ratio = ( posX / renderWidth) / (posY / renderHeight)


	 if ratio >= 1 then 
	(	 -- If Ratio is bigger than 1 then
		  ratio = posY / renderHeight		-- Use Y ratio for calculations
	  ) else 
	(	
		  ratio = posX / renderWidth 		-- Else use X ratio for calculations
	  ) 


	
	global matteValuer = 2.35 
	



thing = ( (renderHeight * ratio) - ((renderWidth/matteValuer) * ratio))  /2  --/ viewAspect 



topmargins = ( (posY as float) - ( thing * 2 ) - ((renderWidth/matteValuer) * ratio ) ) /2  


thing2 = ( (posY as float) - (posY /matteValuer) )  /2 --*ratio


	if viewAspect > imageAspect then 
	(
	topmargins = 0
	)
	

	if viewAspect < imageAspect then
	(
	topmargins = topmargins 
	)
	
	
	if thing2 < 0 then thing2 = (thing2 * -1)


global PosWide = (thing2) + topmargins


gw.hPolyline #([0,PosWide ,0], [posX ,PosWide ,0]) true rgb:#([255,0,0],[255,0,0])

gw.hPolyline #([0,(posY-PosWide) ,0], [posX,(posY-PosWide),0]) true rgb:#([255,0,0],[255,0,0])


gw.enlargeUpdateRect #whole 

gw.updateScreen()




out of curiosity, why would you want to actually render the letterbox bars when you can just not render the required areas and add them in post?

Doing experimenting with previz and postviz with framing shots in cg as well as have way to make own crop scale easily render out to with the exact math.