# Pixel Aspect Ratio

1. If a 16:9 Widescreen has a Pixel Display Ratio of 1.2121:1 then what is the Pixel Display Ratio for a None 4:3 Widescreen?
2. 16:9 widescreen only has a pixel aspect ratio of 40:33 (1.2121...) if the frame size is 704x480. What's a "Pixel Display Ratio"? If you're asking what's the pixel aspect ratio for a 704x480 frame of 4:3 display aspect ratio video -- it's 10:11 (0.9090...).
3. Originally Posted by biferi
If a 16:9 Widescreen has a Pixel Display Ratio of 1.2121:1 then what is the Pixel Display Ratio for a None 4:3 Widescreen?
In what resolution?
4. Any resolution, display aspect ratio and pixel aspect ratio are related in this general formula: PAR x SAR = DAR
6. Originally Posted by Ennio
Any resolution, display aspect ratio and pixel aspect ratio are related in this general formula: PAR x SAR = DAR
No not any resolution, A resolution has to be defined to set the PAR, let's say we have 1440x1080 the PAR (Pixel Aspect Ratio) will be 1:1 or square pixel, If I have 720x480 the PAR will be 8:9 non square, For the example that Jagabo gave above 704x480 the PAR is 10:11, Assuming a 4:3 DAR (Display Aspect Ratio) for all cases according to what the OP is asking for, So no not any resolution.

Originally Posted by Selur

It's hard to know exactly what the OP is asking, there's no context to the question at all
8. Originally Posted by Ennio
Any resolution, display aspect ratio and pixel aspect ratio are related in this general formula: PAR x SAR = DAR
Those followed remarks bring into focus the need to no longer use the "SAR" shortcut crutch.

The true, universal formula, which works in ALL cases - including those requiring transformation to different sizes or ARs - is:
Code:
` DAR = Horiz rez / Vert rez * PAR`
, where DAR = display or frame AR, and PAR = pixel or sample AR.
This formula satisfies dellsam34's resolution variability requirements, and holds true for all the formulae discussed in Selur's threads.

The OP is expecting specific answers to a generality question with an unspoken agenda. Jagabo's answer was probably the best attempt to get to the heart of the spirit of the question, but knowing the OP's history, it might never be sufficient.

Scott
9. Originally Posted by dellsam34
Originally Posted by Ennio
Any resolution, display aspect ratio and pixel aspect ratio are related in this general formula: PAR x SAR = DAR
No not any resolution, A resolution has to be defined to set the PAR, let's say we have 1440x1080 the PAR (Pixel Aspect Ratio) will be 1:1 or square pixel, If I have 720x480 the PAR will be 8:9 non square, For the example that Jagabo gave above 704x480 the PAR is 10:11, Assuming a 4:3 DAR (Display Aspect Ratio) for all cases according to what the OP is asking for, So no not any resolution.
The equation can't be wrong, it is the definition of the system. Just because some commercial systems limit frames to particular dimensions and display aspect ratios (and hence pixel aspect ratios) doesn't invalidate the equation. They all follow the equation. But in theory, any display aspect ratio can be produced from any frame dimensions given the correct pixel aspect ratio -- as defined by the equation.
10. The question is not wrong, it is just not specific. It's like studying the caracteristics of a fluid where we have a general formula defined by pressure P, temperature T and volume V PV=nRT, We know the fluid behaviour based on the general formula but unless we know exactly what fluid is (oil, water ...) there is going to be no specific numbers of P, T or V. I know it's a weird analogy but that's what I was trying to explain in my earlier post.
11. Originally Posted by Cornucopia

The true, universal formula, which works in ALL cases - including those requiring transformation to different sizes or ARs - is:
Code:
` DAR = Horiz rez / Vert rez * PAR`
, where DAR = display or frame AR, and PAR = pixel or sample AR

Scott
Hi,

This equation above is very informative and explains many complex things. However, I recently read on the Internet:

Imported images always stay at their original size. Therefore, you may need to scale your pictures before importing them.
For resizing your picture to fit the project size you can use Imagemagick

Example:
Code:
`convert inputfile.jpg -resize 720x576 outputfile.jpg`
You have to take into account the aspect ratio of your video. For example, PAL images aspect ratio is 4/3, but 720x576 is 5/4. For your imported images to be displayed correctly, you have to rescale their horizontal size:
Code:
`new horizontal size=(5 / 4) / (4 / 3) x original horizontal size`
For PAL videos, you have to multiply the horizontal size of the pictures you want to import by a factor of 0.9375.

Could you, please, explain how the 2-nd second formula (equation) is formed ?
I don't understand why we divide (5 / 4) by (4 / 3) and why we multiply it by original horizontal size ...

Of, course, I understand that 5:4 is Horiz rez / Vert rez for 720x576, 4:3 is DAR for 720x576...
12. I think this may make it much clearer, and tie it into those other formulas...

Code:
`DAR = Horiz rez / Vert rez * PAR`
So,

Call Original image = #1, Final/resized image = #2

DAR1 = Horiz rez1 / Vert rez1 * PAR1
and
DAR2 = Horiz rez2 / Vert rez2 * PAR2

So if you know something that is common, you can substitute ("plug it in").

Let's say, we are keeping the same DAR of 16:9 (aka 1.77777).

1.77777 = Horiz rez1 / Vert rez1 * PAR1
and
1.77777 = Horiz rez2 / Vert rez2 * PAR2

So,
Horiz rez1 / Vert rez1 * PAR1 = Horiz rez2 / Vert rez2 * PAR2

You can plug in your existing info (since you should already have that), and then solve for the remaining unknown(s).

704 / 480 * 1.2121212121 = 1920 / 1080 * PAR2
or
704 / 480 * 1.2121212121 * 1080 / 1920 = PAR2

PAR2 = 1

So par2 is square pixels. Duh.

Not going to comment too much on your example script except to say that they use the number ratio 5/4 in there. That 5/4 comes from using that shortcut "storage AR", which number is a roundabout way of saying this ratio is the shape it would look like if you showed it using only square pixels. Which if you are doing things correctly you are not supposed to do.
But that shortcut ends up making you have to reincorporate those resolution figures anyway, so it's just a convoluted and frankly non-versatile (ok, stupid) way of calculating. And it only covers certain specific use case combinations. Whereas the way I just showed you will work properly in ANY situation.

Scott
13. Originally Posted by mark111
You have to take into account the aspect ratio of your video. For example, PAL images aspect ratio is 4/3, but 720x576 is 5/4. For your imported images to be displayed correctly, you have to rescale their horizontal size:
Code:
`new horizontal size=(5 / 4) / (4 / 3) x original horizontal size`
For PAL videos, you have to multiply the horizontal size of the pictures you want to import by a factor of 0.9375.[/I]

Could you, please, explain how the 2-nd second formula (equation) is formed ?
I don't understand why we divide (5 / 4) by (4 / 3) and why we multiply it by original horizontal size ...
The formula is wrong. You need to divide the original horizontal size by 0.9375, not to multiply.

original horizontal size / ((5/4) / (4/3)) = (original horizontal size / (5/4)) * (4/3)

original horizontal size / (5/4) makes a square from the original frame using storage aspect ratio: 720 / (5/4) = 576 (At this point your pixels are square.)
Then you make a 4x3 rectangle from the square, assuming square pixels: 576 * (4/3) = 768

Clearly, this can be calculated from the vertical size directly using the required proportions, 4:3 or 16:9. For example, a widescreen 576-line video would be 576 * (16/9) = 1024 pixels wide.
14. @Bwaak, please cite us one definitive, authoritative, official engineering document (e.g. ITU/CCIR, SMPTE, NAB, MPEG, NTSC/ATSC, PAL, SECAM, DGA, DCI, etc) that actually specifically mentions "storage aspect ratio" by name (obviously not counting Pixel, Sample, Display & Frame ARs here).
It doesn't exist.
You brought in another example of Wikipedia getting it wrong, unfortunately because it is often crowdsourced by non-experts.

Scott
15. "storage aspect ratio" is still in use here and there. It means the ratio of the physical file resolution.
To quote the site:
Storage aspect ratio (SAR): the dimensions of the video frame, expressed as a ratio. For a 576i video, this is 5:4 (720×576).
https://bavc.org/par-sar-and-dar-making-sense-standard-definition-sd-video-pixels/
16. BAVC? You gotta do better than that.

Scott
17. I don't think this is exactly what you are looking for, but here is a document on a reputable website that mentions the specific keywords:

Originally Posted by EBU: TECH 3390 - EBU-TT, PART M METADATA DEFINITIONS
A single EBU-TT document could be created for re-use to support different renditions of a video asset, where those renditions can themselves have different active video aspect ratios, calculated by multiplying the Storage Aspect Ratio (SAR) by the pixel aspect ratio.
Here is a reference in an Apple's document:

Originally Posted by Apple: MPEG-2 preset in Compressor
Video Property - Anamorphic: This property applies only to standard-definition video. If the source video’s storage aspect ratio doesn’t match its display aspect ratio, you can correct the image so the output doesn’t appear squeezed or stretched. Choose Automatic from the pop-up menu to have Compressor scale the image based on the frame size, or choose 16:9 or 4:3 to scale the image to a specific aspect ratio.
I really don't care what this ratio is called, I just wanted to explain the 5/4 number in the formula.
18. Originally Posted by Cornucopia
Horiz rez1 / Vert rez1 * PAR1 = Horiz rez2 / Vert rez2 * PAR2

Scott
Unfortunately, I don't understand how this equation applies to importing images. This looks more like a meaningless coincidence 1.77=1.77 (AFAIU, of course IMBW).
Please make an example as in the article I quoted.
One more question, how your equation can be used if we add 4:3 footage to a 16:9 anamorphic project and vice versa: a standard 4:3 footage to 16:9 anamorphic project ?
As far as I understand, we have to do scaling and we need to find coefficients..

so it's just a convoluted and frankly non-versatile (ok, stupid) way of calculating. And it only covers certain specific use case combinations.
Could you, please, explain in more detail why and give examples?
I just want to understand how it all works.

Do you agree with the statement from Bwaak that this formula is wrong and we need to divide the original horizontal size by 0.9375, not to multiply ?
If we add images to 720x576 project, we need W_orig multiply by 0.9375 afaiu
19. Originally Posted by mark111
Imported images always stay at their original size. Therefore, you may need to scale your pictures before importing them.
For resizing your picture to fit the project size you can use Imagemagick

Example:
Code:
`convert inputfile.jpg -resize 720x576 outputfile.jpg`
You have to take into account the aspect ratio of your video. For example, PAL images aspect ratio is 4/3, but 720x576 is 5/4. For your imported images to be displayed correctly, you have to rescale their horizontal size:
Code:
`new horizontal size=(5 / 4) / (4 / 3) x original horizontal size`
For PAL videos, you have to multiply the horizontal size of the pictures you want to import by a factor of 0.9375.
Assuming 720x576 should be exactly 4:3
576 x 4 / 3 = 768
768 / 720 = 1.06666666667 <- this is the sample/pixel aspect ratio of the 720x576 anamorphic video
or the other way around
720 / 768 = 0.9375

The example you linked to explains how to fit a 4:3 image into a 5:4 hole by calculating the difference between 5:4 and 4:3.
The same as I did above using 768:576 and 720:576 rather than 4:3 and 5:4.
(5 / 4) / (4 / 3) = 0.9375 or
(4 / 3) / (5 / 4) = 1.06666666667

So for a 4:3 image you multiply the width by 0.9375, or divide it by 1.06666666667, to reduce it for 5:4 dimensions. The 5:4 anamorphic image therefore has a sample/pixel aspect ratio of 1.06666666667.
For a 5:4 anamorphic image you'd multiple the width by 1.06666666667 to give you the width in 4:3 non-anamorphic dimensions.
(the definition of anamorphic I'm using would be any video where the sample/pixel aspect ratio isn't 1:1 or 1.0)

(5 / 4) / (4 / 3) x original horizontal size = new horizontal size
I assume this means the program in question will accept any 5:4 image with a 4:3 display aspect ratio and resize it to 720x576 for you, hence the example only requires you to resize the width. To resize the width of a 4:3 image for an anamorphic 5:4 output, the above formula is correct. 0.9375 * 768 = 720.

But from there you can take any 4:3 image and resize to PAL dimensions by factoring in the sample/pixel aspect ratio.
A 640x480 4:3 video example:

New Width * Pixel Aspect Ratio / Original Width * Original Height = New Height
768 / 640 * 480 = 576
720 * 1.06666666667 / 640 * 480 = 576
The PAL 4:3 sample/pixel aspect ratio is usually referred to as 16:15 (16/15=1.06666666667).
720 * (16 / 15) / (640 / 480) = 576

One more question, how your equation can be used if we add 4:3 footage to a 16:9 anamorphic project and vice versa: a standard 4:3 footage to 16:9 anamorphic project ?
The PAL 16:9 pixel/sample aspect ratio is:
576 x 16 / 9 = 1024
1024 / 720 = 1.42222222222 (64:45)

To add a 4:3 image (768x576) to a 16:9 project, you'd normally pad the left and right sides of the image with black (pillarbox borders) to make it 1024x576 (16:9) and then resize it to 720x576, or resize it to 5:4 dimensions by dividing the width by 1.42222222222.

By the way, if you use Avisynth, try following the CropResize link in my signature.
It can resize to/from anamorphic dimensions and add borders along the way if need be, and all you need to do is specify the correct input aspect ratio (for an anamorphic source), and the desired output aspect ratio if you want an anamorphic output, and Info=true will display the input/output dimensions, display aspect ratio and sample/pixel aspect ratio. There's example screenshots in the second post.
20. My take on this, do not look for a formulas, use simple logic, a code which follows your thoughts what to do with an image.

Formula is one thing but real World does not make it easy. Beside aspect ratios, while inserting an image into a video, you need to follow video mods and subsampling mods! Which means no odd sizes right from the start. It has to be at least mod 2 for width and height. (Has to be divisible by 2) Or some mods have to be 4 because of subsampling of video. Also if using generic images or video you have to consider if you pillabox or letterbox. Not mentioning your image might be rotated, that could be a common occurrence as well.
PAL images aspect ratio is 4/3, but 720x576 is 5/4. For your imported images to be displayed correctly, you have to descale their horizontal size
Regarding PAL or NTSC video and boxing it with a 1:1 square pixel image, do yourself a favor and use Photoshop (even for batch scenarios), it could be Photoshop CS1, 20 years old version. Load PAL DV empty canvas from settings (cannot remember now exact wording) and load you 1:1 images into it. It will adjust proportions accordingly. It was commonly used in DVD era, preparing images for a DVD. Like for DVDLabPro etc. You can also load images to NLE DV projects and software does all calculations for you as well. I cannot imagine other scenarios working with old DV format and images.

Besides DV, boxing your image knowing its SAR into a generic video, you need to follow mods and video subsampling as mentioned!, again that has to be considered, you can follow lines in that python code below (uses vapoursynth, but you can extrapolate it to whatever utility). It will pillarbox or letterbox your image to given video.

clip is your image, ar is its thought SAR and width and height are sizes you are boxing it into.
Code:
```    def to_box(self, clip, width, height, ar=None):
'''
pillarboxes or letterboxes clip into given width and height, keeping aspect ratio,
if clip is anamorphic, proper 1:1 aspect ratio is boxed
'''
cw, ch = clip.width, clip.height
if ar is None:
#no mediainfo ar, check if there is vapoursynth ar
sar_num = vf.get_prop(clip, '_SARNum')
sar_den = vf.get_prop(clip, '_SARDen')
if sar_num and sar_den:
ar = sar_num/sar_den

modx = 1 << clip.format.subsampling_w
mody = 1 << clip.format.subsampling_h

anamorphic = False
if ar is not None and abs(clip.width/clip.height-ar)>0.2:
anamorphic = True
if clip.width > clip.height:
cw = modx * round(clip.height*ar/modx)
else:
ch = mody * round(clip.width*ar/mody)

if width==cw and height==ch and not anamorphic:
return clip

size = 1 << clip.format.bits_per_sample
if clip.format.color_family==vs.RGB:
color=[size//16]*3
else:
color =(size//16, size//2, size//2)

if width/height > cw/ch:
w = cw*height/ch
x = int((width-w)/2)
x = x - x%modx
x = max(0, x)
clip = self.to_size(clip, width-2*x, height)
if x:
logger.debug(f'boxing with left={x} and right={x} borders to {width}x{height}')
else:
return clip
else:
h = ch*width/cw
y = int((height-h)/2)
y = y - y%mody
y = max(0, y)
clip = self.to_size(clip, width, height-2*y)
if y:
logger.debug(f'boxing with top={y} and bottom={y} borders to {width}x{height}')
else:
return clip```
That above does not include rotating image if needed (phone or camera images could be rotated), that is a code on its own.
So as you can see, you cannot fix things just using one formula. I'm sure hello_hello knows it too for example. If it was easy, his codes/utilities would not exist also.
21. Originally Posted by hello_hello
The example you linked to explains how to fit a 4:3 image into a 5:4 hole by calculating the difference between 5:4 and 4:3.
No, vice versa: the example - about how to fit images 5:4 with pixel_ar=1:1 and dar=1.25 to a standart [dar=4:3, pixel_ar=1.33 720:576] project

New Width * Pixel Aspect Ratio / Original Width * Original Height = New Height
How did you get this formula?
22. Will get to full answer later (tonight, tomorrow), but your question just now is in error.

An image/video CANNOT be 5:4 "SAR", AND 1:1 PAR, AND 1.25:1 DAR! At least one of those numbers must be wrong.

Likewise, your standard image/video of 4:3 DAR, AND 4:3 PAR, AND 720x576 resolution also CANNOT be true.

Scott
23. Originally Posted by mark111
Originally Posted by hello_hello
The example you linked to explains how to fit a 4:3 image into a 5:4 hole by calculating the difference between 5:4 and 4:3.
No, vice versa: the example - about how to fit images 5:4 with pixel_ar=1:1 and dar=1.25 to a standart [dar=4:3, pixel_ar=1.33 720:576] project
I don't understand what you're saying there.

Originally Posted by mark111
New Width * Pixel Aspect Ratio / Original Width * Original Height = New Height
How did you get this formula?
If you want to resize a video and it's not anamorphic the dimensions and the display aspect ratio are the same. So a 16:9 video would have 16:9 dimensions and you can pick a new width (for example) and calculate the correct height.
New Width (960) / (16 / 9) = New height (540).
If the video has a non-standard resolution you can just substitute the dimensions, as the dimensions are the DAR (assuming it's not anamorphic). For example, if the original resolution was 1280x540:
New Width [1920] / (Original Width [1280] / Original Height [540]) = New height [810].
or without the brackets:
1920 / 1280 * 540 = 810
Obviously you can re-arrange the equation if necessary. For example if you know you want to resize the height to 800, you have to calculate the matching output width.
800 / 540 * 1280 = 1896

New Width / Original Width * Original Height = New Height
is the basic equation for calculating resizing, but when either the source or the output is anamorphic, the source and output pixel/sample aspect ratios have to be added to the equation.
New Width * Output Pixel Aspect Ratio / (Original Width * Source Pixel Aspect Ratio / Original Height) = New Height

So to resize a PAL 4:3 DVD to NTSC 720x480 4:3 dimensions (the source PAR/SAR is 16:15 and the output PAR/SAR needs to be 8:9).
720 * (8 / 9) / ((720 * (16 / 15)) / 576) = 480
(no need to over-think it though, as all you really need to do is resize the 720x576 image to 720x480 as they both have a 4:3 DAR).

The CropResize function I mentioned earlier will do the math for you.

ColorBars() # resolution 640x480

[Attachment 76549 - Click to enlarge]

Spline36Resize(720, 576) # put the 4:3 color bars into a 5:4 PAL hole.

[Attachment 76550 - Click to enlarge]

CropResize(720,480, InDAR=4.0/3.0, OutDAR=4.0/3.0, Info=true) # put the PAL 4:3 color bars into a 3:2 NTSC hole.

[Attachment 76551 - Click to enlarge]

That's pretty easy because all you need to do is resize the 4:3 image to PAL dimensions, then resize it to NTSC dimensions. However if the image isn't exactly 4:3 and therefore it needs to be cropped to 4:3, or it needs to have borders added to make it 4:3...
Once it's 4:3 though, all you need to do is resize it to 720x576.
24. Reading this whole thread again, I do appreciate @Cornucopia saying the confusing "SAR" phrase can better be avoided and instead use
Code:
` DAR = Horiz rez / Vert rez * PAR`
Will henceforth comply.
25. Originally Posted by Ennio
Reading this whole thread again, I do appreciate @Cornucopia saying the confusing "SAR" phrase can better be avoided and instead use
Code:
` DAR = Horiz rez / Vert rez * PAR`
Will henceforth comply.
Isn't it politically incorrect to refer to samples as pixels these days, or to refer to the aspect ratio of samples as a PAR?

Mind you I'd happily use PAR, even if it's technically incorrect, because if pixels didn't have to be referred to as samples, SAR could be used fairly unambiguously to mean "storage aspect ratio" as god intended.
26. The term "storage aspect ratio" already confuses me, no matter where its definition may have been chiseled in granite. Considering how the --sar argument is meant, the x264.exe devs must be hellbent atheists then. Or am I confusing things already now?
27. Originally Posted by Ennio
The term "storage aspect ratio" already confuses me, no matter where its definition may have been chiseled in granite.
"Storage Aspect Ratio" can make literal sense in some ways functionally - perhaps as the w:h of the (stored), encoded frame size . But you'd need a new fancy acronym because "SAR" is officially taken (or perhaps has been re-taken)

Originally Posted by Ennio
Considering how the --sar argument is meant, the x264.exe devs must be hellbent atheists then. Or am I confusing things already now?
No doubt many were "hellbent" ... but in this case x264 devs were only following the specs. Sample Aspect Ratio is clearly defined as SAR in Rec ITU-T h.264 "AVC" , (and Rec ITU-T h.265 "HEVC", and Rec ITU-T h.266 "VVC") . So SAR is officially the new PAR, and it is (re-)written in stone (and the near-future stone as VVC). But if the past is any indication, "stone" isn't permanent
28. Originally Posted by Ennio
The term "storage aspect ratio" already confuses me, no matter where its definition may have been chiseled in granite. Considering how the --sar argument is meant, the x264.exe devs must be hellbent atheists then. Or am I confusing things already now?
You're not confusing things. The way I remember it, the x264 --sar argument was the final nail in the coffin for referring to resolution as the storage aspect ratio.

Once upon a time:
SAR * PAR = DAR
29. Aha
This does mean I've always mistaken PAR for SAR and vice versa. I hereby offer my sincere apologies to all encoders devs - hellbent or not.
30. It's not just the x264 encoder which eventually adopted the --sar for Sampling Aspect Ratio (aka former PAR for Pixel Aspect Ratio) but it's nailed in the ITU standards for H.264 and H.265.
(SAR for Storage Aspect Ratio was a sort of loose industry definition used in papers and discussions. I have not seen it in any video standard).
Better one always writes down explicitly what one means with the acronyms to avoid confusion.