View Full Version : Aspect ratio problem
pepsimaxx
17th July 2002, 23:30
Well I have these DivX files (PAL source) with a resolution of 512x384. Now I wanna convert them into SVCD but when I do the aspect ratio calculation as mentioned in the Q&A I get an unuseable result as noted below:
Simpleresize(480,590)
AddBorders(0,-7,0,-7)
How do I work around that since my SVCD should be (480,576)? I've read Q63 of the Q&A and I think I need to do some cropping but I can't figure out how to calculate it.
Thanks
gerti67
18th July 2002, 00:22
Hi pepsimaxx,
you're right, you need some cropping as you can't add negative borders. ;)
So you have to decide if you want to keep the width of your DivX or you want to keep the height and do some cropping with the source before resizing to 480x576 for PAL.
I'd prefer to keep the width and crop some lines from the top and the bottom of the source. So you just have to use the formulas and calculate backwards doing just the opposite of what the formulas tell you and starting with your aimed destination height of 576 (instead of the 590).
So you get:
corrected source height = (576 * (54/59) / (720/512) = 374,89
So you now have the correct source height that would give you the result of 576 when using the formulas - try it with 374 and see for yourself. As the values in the script should always be even numbers you can now round up to 376 or down to 374 - it's up to you. When using 376 it is a multiple of 4 and so some MMX optimizations can kick in but the aspect error is slightly (not visible) bigger than with 374.
But your source height is 384 - so you have to crop 10 lines in total from the bottom and the top (384-374=10).
So your script should read like this:
...
Crop(0,5,512,374)
SimpleResize(480,576)
Or when rounding to 376:
...
Crop(0,4,512,376)
SimpleResize(480,576)
Hope this helps,
Gerti
pepsimaxx
18th July 2002, 10:41
Thanks for the detailed calculation Gerti. :)
Just for the sake of it could u also explain how to calculate cropping of width so I know how to do that to? I think I'm gonna do both, watch the results and then decide.
This should really go into the FAQ or Q&A allthough I guess this is rarely an issue.
gerti67
19th July 2002, 00:58
Hi pepsimaxx,
ok here it goes, but if you want to keep the height (384) then you don't have to crop the width - you have to add some borders to the left and the right to maintain the aspect when resizing to 480 x 576.
Our formula to calculate the correct height (CH) of a 1:1 X x Y VGA source was:
CH = ( 720 / X ) * Y * ( 59 / 54 )
When using it with your 512 x 384 DivX you got:
CH = ( 720 / 512 ) * 384 * ( 59 / 54 ) = 590
But the SVCD specs demand a maximum height of 576, so we have to set our CH parameter to 576 and can now decide to solve the equation for X if we want to keep the height of the source or for Y if we want to keep the width of the source.
If we want to keep the width (512) then the source height that can be resized to 480 x 576 can be calculated as followed:
Y = CH * ( X / 720 ) * ( 54 / 59 )
When using it with 512 for X we get:
Y = 576 * ( 512 / 720 ) * ( 54 / 59 ) = 374,89
So we now know that a DivX of 512 x 374 can be directly resized to 480 x 576 maintaining the correct aspect ratio. So we have to crop 10 lines in total from the top and the bottom.
If we want to keep the height (384) then we have to solve the equation for X and we get:
X = ( Y / CH ) * 720 * ( 59 / 54 )
And with Y = 384 we get:
X = ( 384 / 576 ) * 720 * ( 59 / 54 ) = 524,44
So we can see that a source DivX of 524 x 384 can be directly resized to 480 x 576 maintaining the correct aspect ratio but now you have to add some borders to the left and the right to get a width of 524 "pixels" instead of the 512.
So the script should read like this:
...
AddBorders(6,0,6,0)
SimpleResize(480,576)
But you won't see those little black borders because of the TV overscan area - and now that I think about it, I think this method is better because more information of the source DivX is kept and visible with it. ;)
Hope this helps,
Gerti
Daios
1st February 2003, 18:55
I did a search and found this thread. I'm having a similar problem as pepsimaxx in a way. I've been reading this thread and some other threads, guides, faqs, q&a's and I'm confused a bit.
Heres my problem: I also have a divx file that I want to put on a svcd to enjoy on a TV screen. Although I'm trying to fit it for a NTSC format. When I pop the svcd in my dvd player, the picture will be too big for my screen and most of the permanent subtitles are cut off (on both left and right sides on long messages and the bottom half of the subtitle are cut off). my divx file also has a resolution set to 512x384 and when I try to calculate the correct resize settings, I get something that doesn't work or doesn't make sense. At first I checked the Q&A thread (Q62) and tried the formula mentioned and got negative numbers like pepsimaxx did. then I tried Gerti's formula (i don't want to crop the screen since theres subtitles and I want to be able to see the whole screen) with swapping the PAL sizes to NTSC sizes to come out with the correct size. tried it on AVI2SVCD and the outcome still showed all 4 edges to be off the screen. I've tried increasing the border size on all 4 and still no luck.
Heres is my script:
---
LoadPlugin("C:\PROGRA~1\DVD2SVCD\MPEG2Dec\MPEG2D~1.DLL")
AVISource("C:\DOCUME~1\MINIMA~1\Desktop\lovehina\LOF7E1~1.AVI",False)
ConvertToYUY2()
AddBorders(6,0,6,0)
BicubicResize(480,480,0.0,0.6)
---
can someone point me to the right direction? Thanks.
Lecter
1st February 2003, 22:10
Hi, folks
I use a procedure very similar to gerty67 but based on the mean of Resolution (R = X/Y), Display Aspect Ratio (DAR) and Pixel Aspect Ratio (PAR). In a given conversion the product of R x DAR x PAR should be nearly constant so:
[R x DAR x PAR]input = [R x DAR x PAR]output
PC monitor VGA has DAR = 1 and PAR = 1
Fullscreen TV has DAR = 4/3 and Digital Widescrren TV has DAR = 16/9
In case of PAL TV PAR = 54/59 and for NTSC TV, PAR = 11/10.
Accordingly if our input is a Div X video of resolution X = 512 and Y = 384 and our output is a SVCD video for a digital TV PAL, then
(512/384) x 1 x 1 = (X/Y) x 54/59 X 16/9
The output resolution is X/Y = 0.819
Thus, if we keep X = 480 (the standard width of PAL SVCD), then Y = 586 > 576. For this reason Y = 576 is kept instead, which gives X = 472 (approx.). The borders to be added at the edges are (480-472)/2 = about 4 pixels.
If our case is a digital NTSC TV then
(512/384) x 1 x 1 = (X/Y) x 11/10 x 16/9
X/Y = 0.682
Taking Y = 480 we obtain X = 328 (rounded to a even number). In that case the borders to be added are (480-328)/2 = 76.
I hope this could help
Bye
Daios
4th February 2003, 01:14
hmm.. your formula seems like it makes more sense to me, but I tried it and for some reason the video is still shown out of the screen on my tv. I've tried it on 2 dvd players (and TVs) and the same thing happens. the edges are still out of the screen. Top, bottom, and sides are all out of the screen. Enough that part of subtitles are cut off still :(
I've tried it with:
AddBorders(22,0,22,0)
SimpleResize(480,480)
I also tried:
AddBorders(22,22,22,22)
SimpleResize(480,480)
and i got better results for the top and bottom. I guess I just have to play around with the side borders to make it fit as I like.
Has anyone else had problems like this while encoding a 512x384 DivX to NTSC svcd?
Lecter
4th February 2003, 13:42
IMHO, the problem source is that the horizontal dimension cannot be resized to 480. Try the program FitCD (http://http://www.afterdawn.com/software/video_software/video_tools/fitcd.cfm) in order to establish the suitable avisynth script.
I hope this may solve your problem
Bye
onisama
4th February 2003, 19:06
All tv's are going to crop some of the image when it displayed, tyr reducing the output size by 16 or 32 pixels on all four sides and then add either 16 or 32 pixels to the borders of all sides. This will reduce the size of the video. As for the perm subs you need to adjust the hiehgt of where the sub is inserted or add the subs before you resize.
I usually add borders after the resize.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.