JamesHeinrich / getID3

http://www.getid3.org/
Other
1.13k stars 245 forks source link

MPEG-1 pixel aspect ratio is reciprocal of actual value #410

Closed bvibber closed 1 year ago

bvibber commented 1 year ago

Just noticed that for MPEG-1 video, the pixel aspect ratio was coming out as the reciprocal of the desired value. The values in the array in videoAspectRatioLookup are correct to spec but they are reciprocals of the final values, as confirmed by an old note on http://forum.doom9.org/archive/index.php/t-84400.html :

==================================================================================== MPEG-1

Based on "pel_aspect_ratio" located in the Sequence Header

DAR = PAR x SAR

where PAR = the reciprocal of 1.0000, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575 or 1.2015 for pel_aspect_ratio values of "1" thru "14" respectively.

However:

0.9157 is commonly accepted to mean 11/12 or .9166, the reciprocal of 12/11 (1.091) and, 1.0950 is commonly accepted to mean 11/10 or 1.1, the reciprocal of 10/11 (0.909)

====================================================================================

Many MPEG-1 files have square pixels and wouldn't be affected, but those that are encoded for 352x240 or 352x288 from NTSC or PAL television captures will report the wrong aspect ratio. MPEG-2 files listing display aspect ratio are not affected.

This is easily resolved with a one-liner, patch will be attached shortly.

bvibber commented 1 year ago

Here's an example file that's affected. 352x240 4:3 NTSC capture, so pixel aspect ratio should report as <1 (tall) not >1 (wide)

https://brionv.com/media/caesar2k-trailer.mpg