Fix incorrectly-written video rotation metadata even when rotation is baked into the video (fixes #329)

This commit is contained in:
Vanilagy
2026-03-19 14:25:40 +01:00
parent e693765d23
commit 0d50526ff6
5 changed files with 55 additions and 4 deletions
+49
View File
@@ -0,0 +1,49 @@
import { ALL_FORMATS } from '../../src/input-format.js';
import { Input } from '../../src/input.js';
import { Mp4OutputFormat } from '../../src/output-format.js';
import { Output } from '../../src/output.js';
import { BufferSource, UrlSource } from '../../src/source.js';
import { expect, test } from 'vitest';
import { BufferTarget } from '../../src/target.js';
import { Conversion } from '../../src/conversion.js';
import { assert } from '../../src/misc.js';
test('Rotation is baked-in when rerendering', async () => {
using input = new Input({
source: new UrlSource('/rotate-buck-bunny.mp4'),
formats: ALL_FORMATS,
});
const ogTrack = await input.getPrimaryVideoTrack();
assert(ogTrack);
expect(ogTrack.rotation).toBe(90);
expect(ogTrack.codedWidth).toBe(1920);
expect(ogTrack.codedHeight).toBe(1080);
expect(ogTrack.displayWidth).toBe(1080);
expect(ogTrack.displayHeight).toBe(1920);
const output = new Output({
format: new Mp4OutputFormat(),
target: new BufferTarget(),
});
const conversion = await Conversion.init({ input, output, video: {
width: 320,
} });
await conversion.execute();
using newInput = new Input({
source: new BufferSource(output.target.buffer!),
formats: ALL_FORMATS,
});
const track = await newInput.getPrimaryVideoTrack();
assert(track);
expect(track.codedWidth).toBe(320);
expect(track.codedHeight).toBe(570);
expect(track.displayWidth).toBe(320);
expect(track.displayHeight).toBe(570);
expect(track.rotation).toBe(0);
});