Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixel aspect ratio calculation on anamorphic SD MXF #1880

Closed
plondino opened this issue Oct 7, 2023 · 1 comment · Fixed by #1883
Closed

Pixel aspect ratio calculation on anamorphic SD MXF #1880

plondino opened this issue Oct 7, 2023 · 1 comment · Fixed by #1883

Comments

@plondino
Copy link

plondino commented Oct 7, 2023

I have a 720x486 anamorphic SD MXF file. MediaInfo reports the following for the frame info:

Width                                    : 720
Width                                    : 720 pixels
Height                                   : 486
Height                                   : 486 pixels
Height_Offset                            : 26
Height_Offset                            : 26 pixels
Original height                          : 512
Original height                          : 512 pixels
Sampled_Width                            : 720
Sampled_Height                           : 512
Pixel aspect ratio                       : 1.000
Original pixel aspect ratio              : 1.264
Display aspect ratio                     : 1.778
Display aspect ratio                     : 16:9

I am not sure where the 1.0 is coming from here. MXF doesn't store a pixel aspect ratio, rather it stores the Display Aspect Ratio defined in SMPTE ST 377-1 §G.20 as:

The Aspect Ratio shall equal the ratio of width to height of the physical representation of the Display Rectangle as a rational.
Example: {4,3}, {16,9}
Note: Not all display rectangles are constructed from square Pixels.

Since this file has a 16:9 DAR in the MXF wrapper I would expect the math to be:

720/486 @ 16/9 = 864/486
720 * 6/5 = 864

So I would expect MediaInfo to display 1.2 for this asset.

I see the 1.264 as the "Original pixel aspect ratio" which I assume is referring to the Storage or Sampled Height of 512 in the MXF because 720*1.264 = 910.08 / 512 = 1.7775 but since DAR refers to the Display Width/Height that's not the correct calculation.

This works fine for a 4:3 asset:

Width                                    : 720
Width                                    : 720 pixels
Height                                   : 480
Height                                   : 480 pixels
Sampled_Width                            : 720
Sampled_Height                           : 480
Pixel aspect ratio                       : 0.889
Display aspect ratio                     : 1.333
Display aspect ratio                     : 4:3

Where 720 * (8/9) = 640 / 480 = 4/3

I converted the original file to 4:3 letterboxed:

Width                                    : 720
Width                                    : 720 pixels
Height                                   : 486
Height                                   : 486 pixels
Height_Offset                            : 26
Height_Offset                            : 26 pixels
Original height                          : 512
Original height                          : 512 pixels
Sampled_Width                            : 720
Sampled_Height                           : 512
Pixel aspect ratio                       : 1.000
Original pixel aspect ratio              : 0.948
Display aspect ratio                     : 1.333
Display aspect ratio                     : 4:3

It seems to be the same math issue. I would expect:

720/486 @ 4/3 = 648/486
720 * 9/10 = 648

So I would expect the pixel aspect to be 0.9

Also, I agree with MediaArea/MediaInfo#577 - it would be great if MediaInfo had a fractional display for PAR.

@JeromeMartinez JeromeMartinez transferred this issue from MediaArea/MediaInfo Oct 7, 2023
@JeromeMartinez
Copy link
Member

I am not sure where the 1.0 is coming from here.

Default value when there is not Pixel Aspect Ratio. Definitely a bug here as Pixel Aspect Ratio can be retrieved from display Aspect Ratio and width/height, issue visible only when Sampled Height is not Display height.

So I would expect MediaInfo to display 1.2 for this asset.

We found a file in our repository with such issue and fix is on the way.

I see the 1.264 as the "Original pixel aspect ratio" which I assume is referring to the Storage or Sampled Height of 512 in the MXF because 720*1.264 = 910.08 / 512 = 1.7775 but since DAR refers to the Display Width/Height that's not the correct calculation.

Yes. It is due to MPEG-2 Video stream really indicating a DAR of 16:9 for 720x512 so if you demux this stream, a player will show this DAR. I guess this was implemented like this because MPEG-2 Video does not permit arbitrary DAR, but without the MXF container the raw stream has a wrong DAR... We show that in the report.

Also, I agree with MediaArea/MediaInfo#577 - it would be great if MediaInfo had a fractional display for PAR.

We agree too, a design flaw we made ~20 years ago, we wish to put all MediaInfo with fractions everywhere (not only in the report, but also internally, we currently have too many rounding codes everywhere), but it is an unattractive task and cost is not worth it for our sponsors and not a priority (at least up to now ;-) ), so this work is always postponed for later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants