videojs / mux.js

Lightweight utilities for inspecting and manipulating video container formats.
Apache License 2.0
1.11k stars 210 forks source link

fix: Do not scale width by sarRatio, we already generate a pasp box with sarRatio information. #393

Closed brandonocasey closed 3 years ago

brandonocasey commented 3 years ago

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:

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 sarRatio pasp encoding will make the decoder set the width to 320