Fix failing tests, add missing license headers

This commit is contained in:
Vanilagy
2026-04-01 16:39:42 +02:00
parent 5bba924ce5
commit 3c0a6fc299
14 changed files with 59 additions and 31 deletions
+1
View File
@@ -48,6 +48,7 @@ export default tseslint.config(
'eslint.config.mjs',
'docs/.vitepress/cache',
'test/public',
'testfiles_temp'
]
}
);
-21
View File
@@ -1,21 +0,0 @@
const hlsInput = new ManifestInput({
source: new UrlSource('https://example.com/playlist.m3u8'),
formats: [HLS],
});
const variants = await hlsInput.getVariants();
const bestVariant = await hlsInput.getPrimaryVariant();
const qualityVariant = await hlsInput.getVariantFor('1080p'); // In spirit
bestVariant.tracks; // ?
bestVariant.bitrate; // ?
bestVariant.isLive(); // ?
const input = variant.toInput(); // => Input
const segments = variant.getSegments(); // => Segments[]?
const segment = variant.getFirstSegment();
segment.path; // => string (for example 'segment1.ts')
segment.timestamp; // => 10
segment.duration; // 5
segment.toInput(); // => Input
+6
View File
@@ -7,6 +7,8 @@
*/
import { AudioCodec, VideoCodec } from './codec';
import { canDecodeAudioMemo, canDecodeVideoMemo } from './decode';
import { canEncodeAudioMemo, canEncodeVideoMemo } from './encode';
import { MaybePromise } from './misc';
import { EncodedPacket } from './packet';
import { AudioSample, VideoSample } from './sample';
@@ -152,6 +154,7 @@ export const registerDecoder = (decoder: typeof CustomVideoDecoder | typeof Cust
}
customVideoDecoders.push(casted);
canDecodeVideoMemo.clear();
} else if (decoder.prototype instanceof CustomAudioDecoder) {
const casted = decoder as typeof CustomAudioDecoder;
@@ -161,6 +164,7 @@ export const registerDecoder = (decoder: typeof CustomVideoDecoder | typeof Cust
}
customAudioDecoders.push(casted);
canDecodeAudioMemo.clear();
} else {
throw new TypeError('Decoder must be a CustomVideoDecoder or CustomAudioDecoder.');
}
@@ -182,6 +186,7 @@ export const registerEncoder = (encoder: typeof CustomVideoEncoder | typeof Cust
}
customVideoEncoders.push(casted);
canEncodeVideoMemo.clear();
} else if (encoder.prototype instanceof CustomAudioEncoder) {
const casted = encoder as typeof CustomAudioEncoder;
@@ -191,6 +196,7 @@ export const registerEncoder = (encoder: typeof CustomVideoEncoder | typeof Cust
}
customAudioEncoders.push(casted);
canEncodeAudioMemo.clear();
} else {
throw new TypeError('Encoder must be a CustomVideoEncoder or CustomAudioEncoder.');
}
+2 -2
View File
@@ -22,8 +22,8 @@ import {
import { customAudioDecoders, customVideoDecoders } from './custom-coder';
import { isAllowSharedBufferSource, SetOptional } from './misc';
const canDecodeVideoMemo = new Map<string, Promise<boolean>>();
const canDecodeAudioMemo = new Map<string, Promise<boolean>>();
export const canDecodeVideoMemo = new Map<string, Promise<boolean>>();
export const canDecodeAudioMemo = new Map<string, Promise<boolean>>();
const validateVideoDecodingConfig = (codec: VideoCodec, options: SetOptional<VideoDecoderConfig, 'codec'>) => {
if (!options || typeof options !== 'object') {
+2 -2
View File
@@ -26,8 +26,8 @@ import { isFirefox, MaybePromise, Rotation } from './misc';
import { EncodedPacket } from './packet';
import { AudioSample, CropRectangle, validateCropRectangle, VideoSample } from './sample';
const canEncodeVideoMemo = new Map<string, Promise<boolean>>();
const canEncodeAudioMemo = new Map<string, Promise<boolean>>();
export const canEncodeVideoMemo = new Map<string, Promise<boolean>>();
export const canEncodeAudioMemo = new Map<string, Promise<boolean>>();
/**
* Configuration object that controls video encoding. Can be used to set codec, quality, and more.
+4 -4
View File
@@ -49,16 +49,16 @@ export class FlacMuxer extends Muxer {
super(output);
this.format = format;
if (this.format._options.appendOnly) {
this.writer.ensureMonotonicity();
}
}
async start() {
const release = await this.mutex.acquire();
this.writer = await this.output._getRootWriter();
if (this.format._options.appendOnly) {
this.writer.ensureMonotonicity();
}
this.writer.write(FLAC_HEADER);
release();
+8
View File
@@ -1,3 +1,11 @@
/*!
* Copyright (c) 2026-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { AUDIO_CODECS, AudioCodec, inferCodecFromCodecString, MediaCodec, VIDEO_CODECS, VideoCodec } from '../codec';
import { Demuxer, DurationMetadataRequestOptions } from '../demuxer';
import { Input } from '../input';
+8
View File
@@ -1,3 +1,11 @@
/*!
* Copyright (c) 2026-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
export const canIgnoreLine = (line: string) => line.length === 0 || (line.startsWith('#') && !line.startsWith('#EXT'));
export class AttributeList {
+8
View File
@@ -1,3 +1,11 @@
/*!
* Copyright (c) 2026-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { MediaCodec, validateAudioChunkMetadata, validateVideoChunkMetadata } from '../codec';
import { EncodedAudioPacketSource, EncodedVideoPacketSource } from '../media-source';
import { arrayArgmax, assert, findLastIndex, joinPaths, textEncoder, toArray, UNDETERMINED_LANGUAGE } from '../misc';
+8
View File
@@ -1,3 +1,11 @@
/*!
* Copyright (c) 2026-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { AES_128_BLOCK_SIZE, createAes128CbcDecryptStream } from '../aes';
import { ENCRYPTION_KEY_CACHE_GROUP, Input } from '../input';
import { Segment, SegmentedInput, SegmentRetrievalOptions } from '../segmented-input';
+8
View File
@@ -1,3 +1,11 @@
/*!
* Copyright (c) 2026-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { assert } from './misc';
import { AudioSample } from './sample';
+1 -1
View File
@@ -52,7 +52,7 @@ test('can convert a .flac to .wav', async () => {
assert(outputTrack);
const duration = await outputTrack.computeDuration();
expect(duration).toBe(19.71428571428571);
expect(duration).toBe(19.714285714285715);
const tags = await outputAsInput.getMetadataTags();
expect(tags.raw).toEqual({
IART: 'Samples Files',
+2
View File
@@ -41,6 +41,7 @@ test('Default track disposition', async () => {
original: false,
hearingImpaired: false,
visuallyImpaired: false,
primary: false,
commentary: false,
});
});
@@ -87,6 +88,7 @@ test('Customized track disposition', async () => {
original: true,
hearingImpaired: true,
visuallyImpaired: true,
primary: false,
commentary: true,
});
});
+1 -1
View File
@@ -21,7 +21,7 @@ test('can loop over all samples', async () => {
const track = await input.getPrimaryAudioTrack();
assert(track);
expect(await track.computeDuration()).toEqual(19.71428571428571);
expect(await track.computeDuration()).toEqual(19.714285714285715);
expect(await track.getDecoderConfig()).toEqual({
codec: 'flac',
numberOfChannels: 2,