Ok. I started this thread in the Mac sub-forum because I had a question on how to properly calculate a new size for a video that was being encoded for viewing on a set-top DVD player. The guys in the thread were extremely helpful and while they didn't explain the formula they were using to determine new frame size, they did provide some general guidelines based on the video sizes that I had encountered thus far.
However, last night, I was again forced to look at the subject of how to properly calculate new frame size when I got a vid with a current size of 608x256. I started Googling and landed on this site. While there are several examples on the page about how to calculate new frame sizes when resizing a video, the one that was most poignant was this:
For the most part, I can follow along with what's going on in the formula (with a little help with a Calculator as I was NEVER any good at fractions....); There's just one bit that confuses me and if someone could help me figure this out, I can then work the rest out on my own.When you can't keep the same DAR (Display Aspect Ratio)
Return to example 2, where an AVI video file was transcoded to MPEG. Now suppose that the AVI file is 672x272 with a PAR of 1:1, giving a DAR of 42:17. DVD players do not support this aspect ratio, and you cannot simply keep the same video frame size because DVD players require a fixed size (720x480, 704x480, 352x480, or 352x240 for NTSC). Worse, DVD video does not allow a PAR of 1:1. So what can you do?
Solving this requires two steps: zooming the input video to change the PAR (while keeping the DAR constant), then adding borders to change the DAR (while keeping the new PAR constant). First, let's assume that the output DVD will have a DAR of 16:9, since that is closer to the input video's 42:17 (about 2.5:1) than a DAR of 4:3. We'll also choose the largest possible DVD frame size, 720x480. From these we can see that the PAR of the DVD video stream will be:
height * DAR 480 * (16/9)
PAR = ------------ = ------------ = 32/27
Next we need to determine the size to zoom the input video to. As in examples 3 and 4, we hold either the width or the height constant to come up with two possible sizes. Note that here, we use the DAR of our input video, not the DAR of the DVD, because we don't want to stretch the video.
height = 480, width = (DAR * height) / PAR = (42/17 * 480) / (32/27) = 1000 (1000x480)
width = 720, height = (PAR * width ) / DAR = (32/27 * 720) / (42/17) = 346 ( 720x346)
(As in example 4, these are rounded to even numbers due to the requirements of the video codec.) Since 1000x480 is too large for DVD, we instead choose 720x346 as the zoom size.
Finally, we need to add a border to the video so that it matches the desired output frame size of 720x480. This is done with the -Y option, which is processed after -Z (as opposed to the -j option used in Example 4, which is handled before -Z and is used for clipping or adding borders to the input frame). The difference between the zoomed frame and the output frame size is 480 - 346 = 134 pixels, so we should add half of that, or 67 pixels, to the top and bottom of the frame. But again, these values must be even, so we have to use 68 and 66 instead. (This will shift the video slightly above or below the center position of the display.)
Thus our transcode options are (remembering that "3" is the aspect ratio code for 16:9):
-Z 720x346 -Y -68,0,-66,0 --export_asr 3
What I don't get is how that DAR of 42:17 was determined. Is it calculated by dividing the width of the original vid by it's height? Or is it dividing height by width? Or is that both are wrong and the DAR is calculated by some other means? If I could just figure this out then it should be easy to calculate new frame size by using the bottom equation and plugging the DAR of the video in since all of the vids that I will resize will be for viewing on a DVD player (allowing to maintain a width of 720).Now suppose that the AVI file is 672x272 with a PAR of 1:1, giving a DAR of 42:17.
If anyone could offer any help or insight, I would be really grateful.
Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker or buy PlayOn (record Netflix) :)
Please consider supporting us by disabling your ad blocker or buy PlayOn (record Netflix) :)
+ Reply to Thread
Results 1 to 14 of 14
My opinion is that you're making it more difficult than it really is.
And 2.47:1 represents the ratio of the width to the height of that particular AVI.
In addition, you have no idea whether or not the AVI you downloaded was even cropped and resized correctly to begin with, so why quibble over fractions of a percent when trying to resize for DVD? Didn't I point you to FitCD for resizing in that other thread? Maybe you can't use AviSynth in a Mac environment (yet), but you can easily get the resize values and how much black you need to pad out the video for encoding to MPEG-2. Here's FulciLives' guide to using FitCD:
And of course DJRumpy has a lot of commonsensical advice in his long post. But all you're doing is giving yourself a headache if you place too much stock in information such as that contained in the link of yours. I don't say it's wrong. I'm only saying you don't need to know it in order to crop, resize, and add black to your videos prior to encoding for MPEG-2. And there are only 2 DARs for DVD, 4:3 and 16:9.
If you must know, he divided 672 and 272 by 16, the greatest common denominator. But there's no reason to calculate that ratio. Just use 672:272 anywhere he used 42:17.
I posted it to show him how to figure out the math for himself. He specifically wanted to know how to figure out the formula for the frame size.
I really should update it though. It's gotten a little dated in the last 4 years..lolImpossible to see the future is. The Dark Side clouds everything...
Originally Posted by hydrophonicaudio
I would not use that method, everything can be done much easier. The aim is to just determine height of new image inside MPEG 720x480 matrix representing a 16:9 (or 4:3 in other case) image. Let's assume AR from the example 2.47:1 (taken from avi pixels; a bit different from standard 2.35:1 but possible if someone cropped the image for some reason). 16:9=1.78.. and the height will be 480x1.78/2.47=345; it should be rounded to something like 344 (multiple of 8 ).
So just resize your source to 720x344, add 68+68 borders and encode as 16:9, don't cry for MAC version of FitCD!
Originally Posted by DJRumpy
For the anal retentive that absolutely have to know how it works, I suppose pages like that can be useful, but with apps like FitCD and GKnot around to do the work for us, then why bother? I have a degree in mathematics, so I don't have any problem getting my head around that stuff, but just have other things with which to waste my time.
I don't think it's anal retentive to want to understand why the numbers we use are there at all. I'm certainly not anal retentive, just naturally curious.
Way back when I posted that guide years ago, there was no one answering those questions.Impossible to see the future is. The Dark Side clouds everything...
For square pixel sources the resizing can be further simplified. Given a square pixel source of WxH pixels:
To make a 4:3 NTSC DVD:
W' = 704 H' = H * 640 / W
W' = 704 H' = H * 853 / W
W'' = W' * 480 / H' H'' = 480
Finally, pad the frame with black borders to get a frame size of 704x480, or 720x480 if you prefer.
If you want to know where 640 in the first equation comes from: 480 * 4 / 3.
853 in the second equation comes from 480 * 16 / 9 (actually 853.333...).
First, let me say thank for the overwhelming response to this post. I definitely feel that this is the absolute best place to go in terms of getting these various questions answered.
Now let me clear up a few things......
I posted this because I'm not trying to make my task in resizing these vids harder...I really wish there was an easier way to do this. Unfortunately, on the Mac, no one has programmed versions of FitCD or GKnot that work on the Mac. The tools that we do use most often (ffmpegX, VisualHub and Handbrake) allow you to put in sizes for resizing a vid, but they don't calculate those numbers for you.....you are expecting to know the new frame size and how much padding to add beforehand.
Consequently, I could just write a post everytime I get a weird dimension like 608x256 and wait for someone to reply with the needed dimensions, but that would be abusing this board. I believe that the knowledgeable people on the board like Fulci, DJ, Case and Manano post info so that people can learn how to do things for themselves and that is what I was trying to do.
The last thread that I made in the Mac sub-forums is great...you guys posted info that has really gotten me through these past few days. But I still haven't learned how to properly calculate these numbers on my own, which I feel we should all know how to do, regardless if we have tools at our disposal or not that do these things for us.
Lastly, I posted this in the newbie sub-forum instead of the Mac sub-forum, as I'm sure I'm not the only individual that has questions about how to do this. Had I known about DJ's post beforehand, maybe I wouldn't have made this rather long post, but I didn't and so here we are. Maybe my search keywords were off, but I honestly didn't know about his post.
Again...I want to thank everyone that has responded. This has truly been educational and very enlightening for me. Now I am off to read DJ's commonsensical post.......
If you know correct DAR for the source video, pixel type doesn't matter in calculations (no need to use pixel numbers). It is always enough to re-calculate vertical size (horizontal is always 720) of letterboxed image using the known DAR (either 16:9 or 4:3) of standard MPEG (720x480 or 720x576) and DAR of the source video. The numbers are in simple proportion and you can always get the height from the single equation (NTSC):
where DAR1=1.777... for 16:9 MPEG encoding (1.333... for letterboxing in 4:3),
DAR2 is displayed aspect ratio of the source video (also in decimal fraction form); this gives resize numbers 720xH and top/bottom borders should be added (480-H)/2. I gave an example in earlier post.
As usual, the result can be rounded and corrected for 704 if needed. For PAL 576 can be used in equation instead of 480.
Originally Posted by Alex_ander
H' = 480 x DAR1 / DAR2
H' = 480 * 1.333 / DAR2
H' = 640 / DAR2
H' = 640 / (W / H)
H' = 640 * H / W
H' = 480 x DAR1 / DAR2
H' = 480 * 1.777 / DAR2
H' = 853 / DAR2
H' = 853 / (W / H)
H' = 853 * H / W
Yes, it's about the same in shorter form. BTW, this approach also works in case one wants to fill the screen instead of letterboxing (that was the first question in MAC' thread). E.g. if you want to convert this way a video with DAR2 4:3 (or the like) to 16:9, you'll get H>480 from the equation. Then you still resize to (720xH) and in the end simply crop totally (H-480) and this keeps correct image proportions.
The remaining possible case is when pillarboxing (or smth. like 16:9 to 4:3 fill-screen conversion) is needed. Then a similar equation should work for width calculation:
and the final resize numbers will be Wx480 (Wx576 for PAL), in case W>720 (W-720) can be cropped after resizing (fill-screen case), otherwise vertical borders of the same total size should be added.
Here's a simple 'commonsensual' guide table for any possible case:
DAR1 is either 16/9 or 4/3 (one of the 2 standard DVD settings planned for encoding),
DAR2 can be anything and is the source video parameter; in simple case (for an avi with correct proportions) it can be obtained by dividing pixel numbers, otherwise (e.g. if the source video was created by unknown person) experimenting or additional information may be needed to estimate it correctly.
H1=480(NTSC) or H1=576(PAL) - standard DVD image height.
Preet, preet, why are you digging up a nearly 4-year-old thread on the subject of aspect ratio to ask an unrelated question?
You can learn about GOP structure here: http://en.wikipedia.org/wiki/MPEG-2 and you can find out a lot of other DVD info here: http://www.videohelp.com/dvd#tech.
As for the specifics on a certain video, you can always open it in either GSpot or MediaInfo.