mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 00:33:46 +02:00
Merge branch 'main' into hls
This commit is contained in:
@@ -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);
|
||||
});
|
||||
@@ -87,8 +87,8 @@ test('Pixel aspect ratio transcode conversion', async () => {
|
||||
expect(mp4.snapshot.squarePixelHeight).toBe(mp4.snapshot.codedHeight);
|
||||
expect(mp4.snapshot.displayWidth).toBe(mp4.snapshot.codedWidth);
|
||||
expect(mp4.snapshot.displayHeight).toBe(mp4.snapshot.codedHeight);
|
||||
expect(mp4.snapshot.decoderDisplayAspectWidth).toBe(mp4.snapshot.codedWidth);
|
||||
expect(mp4.snapshot.decoderDisplayAspectHeight).toBe(mp4.snapshot.codedHeight);
|
||||
expect(mp4.snapshot.decoderDisplayAspectWidth).toBeUndefined();
|
||||
expect(mp4.snapshot.decoderDisplayAspectHeight).toBeUndefined();
|
||||
|
||||
expect(mp4.snapshot.codedWidth).toBe(source.squarePixelWidth);
|
||||
expect(mp4.snapshot.codedHeight).toBe(source.squarePixelHeight);
|
||||
|
||||
@@ -254,3 +254,33 @@ test('can re-mux a .flac', async () => {
|
||||
|
||||
expect(otherInputDecoderConfig).toEqual(otherOutputDecoderConfig);
|
||||
});
|
||||
|
||||
test('appendOnly writes correct STREAMINFO header', async () => {
|
||||
const filePath = path.join(__dirname, '..', 'public/sample.flac');
|
||||
using input = new Input({
|
||||
source: new FilePathSource(filePath),
|
||||
formats: ALL_FORMATS,
|
||||
});
|
||||
|
||||
const target = new BufferTarget();
|
||||
const output = new Output({
|
||||
format: new FlacOutputFormat({ appendOnly: true }),
|
||||
target,
|
||||
});
|
||||
|
||||
const conversion = await Conversion.init({ input, output });
|
||||
await conversion.execute();
|
||||
|
||||
assert(target.buffer);
|
||||
const bytes = new Uint8Array(target.buffer);
|
||||
|
||||
// STREAMINFO: min_block=16, max_block=65535, min_frame=0, max_frame=0
|
||||
expect(bytes.slice(8, 18)).toEqual(new Uint8Array([
|
||||
// minimum_block_size=16
|
||||
0x00, 0x10,
|
||||
// maximum_block_size=65535
|
||||
0xFF, 0xFF,
|
||||
// minimum_frame_size=0
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
]));
|
||||
});
|
||||
|
||||
@@ -46,8 +46,6 @@ test('MPEG-TS metadata reading', async () => {
|
||||
codec: 'avc1.640020',
|
||||
codedWidth: 720,
|
||||
codedHeight: 720,
|
||||
displayAspectWidth: 720,
|
||||
displayAspectHeight: 720,
|
||||
colorSpace: {
|
||||
primaries: 'bt2020',
|
||||
transfer: 'hlg',
|
||||
@@ -561,8 +559,6 @@ test('MPEG-TS with HEVC video', async () => {
|
||||
codec: 'hev1.1.6.L120.90',
|
||||
codedWidth: 1920,
|
||||
codedHeight: 1080,
|
||||
displayAspectWidth: 1920,
|
||||
displayAspectHeight: 1080,
|
||||
colorSpace: {
|
||||
primaries: 'bt709',
|
||||
transfer: 'bt709',
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user