While this doesn't give us the absolute width when we have a sarRatio, we don't want to use the absolute width. This is because we already encode the sarRatio in the pasp atom of our mp4 output. By encoding the sarRatio and an absolute width, the width is skewed even further unless the decoder looks directly at the nal units and calculates it itself. Example:
sarRatio is 0.5
width is 640 without sarRatio
How it is now with sarRatio width would get set to 320 and then when the decoder see's the pasp atom with sarRatio it will think that width is 160. Some decoders will ignore all these values on use nal units to calculate the width, but mobile Samsung Chrome on Android 11 will not. This causes a media decode error as the actual width of the video is 320.
With this change width will be set to 640 and the sarRatiopasp encoding will make the decoder set the width to 320
While this doesn't give us the absolute width when we have a
sarRatio
, we don't want to use the absolute width. This is because we already encode thesarRatio
in thepasp
atom of our mp4 output. By encoding thesarRatio
and an absolute width, the width is skewed even further unless the decoder looks directly at the nal units and calculates it itself. Example:sarRatio
is0.5
width
is640
withoutsarRatio
How it is now with
sarRatio
width would get set to320
and then when the decoder see's thepasp
atom withsarRatio
it will think that width is160
. Some decoders will ignore all these values on use nal units to calculate the width, but mobile Samsung Chrome on Android 11 will not. This causes a media decode error as the actual width of the video is320
.With this change width will be set to
640
and thesarRatio
pasp
encoding will make the decoder set the width to320