From ad26edc6b53019c3da7d40f9f04a2ff6c3f22acf Mon Sep 17 00:00:00 2001 From: Vanilagy <1696106+Vanilagy@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:49:33 +0200 Subject: [PATCH] Catch degenerate ISOBMFF matrices --- src/isobmff/isobmff-demuxer.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/isobmff/isobmff-demuxer.ts b/src/isobmff/isobmff-demuxer.ts index 20723ff..ba5ec2d 100644 --- a/src/isobmff/isobmff-demuxer.ts +++ b/src/isobmff/isobmff-demuxer.ts @@ -2755,7 +2755,14 @@ const extractRotationFromMatrix = (matrix: TransformationMatrix) => { const sinTheta = m21 / scaleX; // Invert the rotation because matrices are post-multiplied in ISOBMFF - return -Math.atan2(sinTheta, cosTheta) * (180 / Math.PI); + const result = -Math.atan2(sinTheta, cosTheta) * (180 / Math.PI); + + if (!Number.isFinite(result)) { + // Can happen if the entire matrix is 0, for example + return 0; + } + + return result; }; const sampleTableIsEmpty = (sampleTable: SampleTable) => {