🎥 Make videos programmatically with React
Update rotate-and-resize-video-frame.ts
Jonny Burger818467b9bd88
diff --git a/packages/webcodecs/src/rotate-and-resize-video-frame.ts b/packages/webcodecs/src/rotate-and-resize-video-frame.tsindex f6b477c025..682a1dac7f 100644--- a/packages/webcodecs/src/rotate-and-resize-video-frame.ts+++ b/packages/webcodecs/src/rotate-and-resize-video-frame.ts@@ -56,16 +56,22 @@ export const rotateAndResizeVideoFrame = ({canvas.width = width;canvas.height = height;- if (normalized === 90) {+ // @ts-expect-error+ const frameRotation: number = frame.rotation ?? 0;+ const canvasRotationToApply = normalizeVideoRotation(+ normalized + frameRotation,+ );++ if (canvasRotationToApply === 90) {ctx.translate(width, 0);- } else if (normalized === 180) {+ } else if (canvasRotationToApply === 180) {ctx.translate(width, height);- } else if (normalized === 270) {+ } else if (canvasRotationToApply === 270) {ctx.translate(0, height);}- if (normalized !== 0) {- ctx.rotate(normalized * (Math.PI / 180));+ if (canvasRotationToApply !== 0) {+ ctx.rotate(canvasRotationToApply * (Math.PI / 180));}if (frame.displayHeight !== height || frame.displayWidth !== width) {