From a1008b80888205d5d86a343b2ddc84692640065e Mon Sep 17 00:00:00 2001 From: Vanilagy <1696106+Vanilagy@users.noreply.github.com> Date: Fri, 26 Sep 2025 16:31:24 +0200 Subject: [PATCH] Fix invalid crop region for rotated video samples (fixes #151) --- dev/convert.html | 9 +++++---- src/sample.ts | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dev/convert.html b/dev/convert.html index 565c9a5..1832b5f 100644 --- a/dev/convert.html +++ b/dev/convert.html @@ -24,7 +24,7 @@ chunked: true, chunkSize: 2**20 }); - const outputFormat = new Mediabunny.Mp3OutputFormat({}); + const outputFormat = new Mediabunny.Mp4OutputFormat({}); const button = document.createElement('button'); button.textContent = 'Cancel'; @@ -92,6 +92,7 @@ }, */ video: () => ({ + width: 300, //alpha: 'keep', //width: 320, //discard: true, @@ -128,7 +129,7 @@ //width: 200, //height: 100, }), - tags: { + tags: {} ?? { title: 'Bigggy', artist: 'Buck Bunny', images: [{ @@ -146,8 +147,8 @@ } }, trim: { - start: 10, - //end: 20 + start: 0, + end: 10 }, }); console.log(conversion); diff --git a/src/sample.ts b/src/sample.ts index 5f537da..805aebe 100644 --- a/src/sample.ts +++ b/src/sample.ts @@ -620,8 +620,8 @@ export class VideoSample implements Disposable { const { sx, sy, sWidth, sHeight } = this._rotateSourceRegion( options.crop?.left ?? 0, options.crop?.top ?? 0, - options.crop?.width ?? this.codedWidth, - options.crop?.height ?? this.codedHeight, + options.crop?.width ?? rotatedWidth, + options.crop?.height ?? rotatedHeight, rotation, );