mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
Fix failing tests, add missing license headers
This commit is contained in:
@@ -48,6 +48,7 @@ export default tseslint.config(
|
|||||||
'eslint.config.mjs',
|
'eslint.config.mjs',
|
||||||
'docs/.vitepress/cache',
|
'docs/.vitepress/cache',
|
||||||
'test/public',
|
'test/public',
|
||||||
|
'testfiles_temp'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AudioCodec, VideoCodec } from './codec';
|
import { AudioCodec, VideoCodec } from './codec';
|
||||||
|
import { canDecodeAudioMemo, canDecodeVideoMemo } from './decode';
|
||||||
|
import { canEncodeAudioMemo, canEncodeVideoMemo } from './encode';
|
||||||
import { MaybePromise } from './misc';
|
import { MaybePromise } from './misc';
|
||||||
import { EncodedPacket } from './packet';
|
import { EncodedPacket } from './packet';
|
||||||
import { AudioSample, VideoSample } from './sample';
|
import { AudioSample, VideoSample } from './sample';
|
||||||
@@ -152,6 +154,7 @@ export const registerDecoder = (decoder: typeof CustomVideoDecoder | typeof Cust
|
|||||||
}
|
}
|
||||||
|
|
||||||
customVideoDecoders.push(casted);
|
customVideoDecoders.push(casted);
|
||||||
|
canDecodeVideoMemo.clear();
|
||||||
} else if (decoder.prototype instanceof CustomAudioDecoder) {
|
} else if (decoder.prototype instanceof CustomAudioDecoder) {
|
||||||
const casted = decoder as typeof CustomAudioDecoder;
|
const casted = decoder as typeof CustomAudioDecoder;
|
||||||
|
|
||||||
@@ -161,6 +164,7 @@ export const registerDecoder = (decoder: typeof CustomVideoDecoder | typeof Cust
|
|||||||
}
|
}
|
||||||
|
|
||||||
customAudioDecoders.push(casted);
|
customAudioDecoders.push(casted);
|
||||||
|
canDecodeAudioMemo.clear();
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError('Decoder must be a CustomVideoDecoder or CustomAudioDecoder.');
|
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);
|
customVideoEncoders.push(casted);
|
||||||
|
canEncodeVideoMemo.clear();
|
||||||
} else if (encoder.prototype instanceof CustomAudioEncoder) {
|
} else if (encoder.prototype instanceof CustomAudioEncoder) {
|
||||||
const casted = encoder as typeof CustomAudioEncoder;
|
const casted = encoder as typeof CustomAudioEncoder;
|
||||||
|
|
||||||
@@ -191,6 +196,7 @@ export const registerEncoder = (encoder: typeof CustomVideoEncoder | typeof Cust
|
|||||||
}
|
}
|
||||||
|
|
||||||
customAudioEncoders.push(casted);
|
customAudioEncoders.push(casted);
|
||||||
|
canEncodeAudioMemo.clear();
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError('Encoder must be a CustomVideoEncoder or CustomAudioEncoder.');
|
throw new TypeError('Encoder must be a CustomVideoEncoder or CustomAudioEncoder.');
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -22,8 +22,8 @@ import {
|
|||||||
import { customAudioDecoders, customVideoDecoders } from './custom-coder';
|
import { customAudioDecoders, customVideoDecoders } from './custom-coder';
|
||||||
import { isAllowSharedBufferSource, SetOptional } from './misc';
|
import { isAllowSharedBufferSource, SetOptional } from './misc';
|
||||||
|
|
||||||
const canDecodeVideoMemo = new Map<string, Promise<boolean>>();
|
export const canDecodeVideoMemo = new Map<string, Promise<boolean>>();
|
||||||
const canDecodeAudioMemo = new Map<string, Promise<boolean>>();
|
export const canDecodeAudioMemo = new Map<string, Promise<boolean>>();
|
||||||
|
|
||||||
const validateVideoDecodingConfig = (codec: VideoCodec, options: SetOptional<VideoDecoderConfig, 'codec'>) => {
|
const validateVideoDecodingConfig = (codec: VideoCodec, options: SetOptional<VideoDecoderConfig, 'codec'>) => {
|
||||||
if (!options || typeof options !== 'object') {
|
if (!options || typeof options !== 'object') {
|
||||||
|
|||||||
+2
-2
@@ -26,8 +26,8 @@ import { isFirefox, MaybePromise, Rotation } from './misc';
|
|||||||
import { EncodedPacket } from './packet';
|
import { EncodedPacket } from './packet';
|
||||||
import { AudioSample, CropRectangle, validateCropRectangle, VideoSample } from './sample';
|
import { AudioSample, CropRectangle, validateCropRectangle, VideoSample } from './sample';
|
||||||
|
|
||||||
const canEncodeVideoMemo = new Map<string, Promise<boolean>>();
|
export const canEncodeVideoMemo = new Map<string, Promise<boolean>>();
|
||||||
const canEncodeAudioMemo = 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.
|
* Configuration object that controls video encoding. Can be used to set codec, quality, and more.
|
||||||
|
|||||||
@@ -49,16 +49,16 @@ export class FlacMuxer extends Muxer {
|
|||||||
super(output);
|
super(output);
|
||||||
|
|
||||||
this.format = format;
|
this.format = format;
|
||||||
|
|
||||||
if (this.format._options.appendOnly) {
|
|
||||||
this.writer.ensureMonotonicity();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
const release = await this.mutex.acquire();
|
const release = await this.mutex.acquire();
|
||||||
|
|
||||||
this.writer = await this.output._getRootWriter();
|
this.writer = await this.output._getRootWriter();
|
||||||
|
if (this.format._options.appendOnly) {
|
||||||
|
this.writer.ensureMonotonicity();
|
||||||
|
}
|
||||||
|
|
||||||
this.writer.write(FLAC_HEADER);
|
this.writer.write(FLAC_HEADER);
|
||||||
|
|
||||||
release();
|
release();
|
||||||
|
|||||||
@@ -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 { AUDIO_CODECS, AudioCodec, inferCodecFromCodecString, MediaCodec, VIDEO_CODECS, VideoCodec } from '../codec';
|
||||||
import { Demuxer, DurationMetadataRequestOptions } from '../demuxer';
|
import { Demuxer, DurationMetadataRequestOptions } from '../demuxer';
|
||||||
import { Input } from '../input';
|
import { Input } from '../input';
|
||||||
|
|||||||
@@ -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 const canIgnoreLine = (line: string) => line.length === 0 || (line.startsWith('#') && !line.startsWith('#EXT'));
|
||||||
|
|
||||||
export class AttributeList {
|
export class AttributeList {
|
||||||
|
|||||||
@@ -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 { MediaCodec, validateAudioChunkMetadata, validateVideoChunkMetadata } from '../codec';
|
||||||
import { EncodedAudioPacketSource, EncodedVideoPacketSource } from '../media-source';
|
import { EncodedAudioPacketSource, EncodedVideoPacketSource } from '../media-source';
|
||||||
import { arrayArgmax, assert, findLastIndex, joinPaths, textEncoder, toArray, UNDETERMINED_LANGUAGE } from '../misc';
|
import { arrayArgmax, assert, findLastIndex, joinPaths, textEncoder, toArray, UNDETERMINED_LANGUAGE } from '../misc';
|
||||||
|
|||||||
@@ -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 { AES_128_BLOCK_SIZE, createAes128CbcDecryptStream } from '../aes';
|
||||||
import { ENCRYPTION_KEY_CACHE_GROUP, Input } from '../input';
|
import { ENCRYPTION_KEY_CACHE_GROUP, Input } from '../input';
|
||||||
import { Segment, SegmentedInput, SegmentRetrievalOptions } from '../segmented-input';
|
import { Segment, SegmentedInput, SegmentRetrievalOptions } from '../segmented-input';
|
||||||
|
|||||||
@@ -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 { assert } from './misc';
|
||||||
import { AudioSample } from './sample';
|
import { AudioSample } from './sample';
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ test('can convert a .flac to .wav', async () => {
|
|||||||
assert(outputTrack);
|
assert(outputTrack);
|
||||||
|
|
||||||
const duration = await outputTrack.computeDuration();
|
const duration = await outputTrack.computeDuration();
|
||||||
expect(duration).toBe(19.71428571428571);
|
expect(duration).toBe(19.714285714285715);
|
||||||
const tags = await outputAsInput.getMetadataTags();
|
const tags = await outputAsInput.getMetadataTags();
|
||||||
expect(tags.raw).toEqual({
|
expect(tags.raw).toEqual({
|
||||||
IART: 'Samples Files',
|
IART: 'Samples Files',
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ test('Default track disposition', async () => {
|
|||||||
original: false,
|
original: false,
|
||||||
hearingImpaired: false,
|
hearingImpaired: false,
|
||||||
visuallyImpaired: false,
|
visuallyImpaired: false,
|
||||||
|
primary: false,
|
||||||
commentary: false,
|
commentary: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -87,6 +88,7 @@ test('Customized track disposition', async () => {
|
|||||||
original: true,
|
original: true,
|
||||||
hearingImpaired: true,
|
hearingImpaired: true,
|
||||||
visuallyImpaired: true,
|
visuallyImpaired: true,
|
||||||
|
primary: false,
|
||||||
commentary: true,
|
commentary: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ test('can loop over all samples', async () => {
|
|||||||
|
|
||||||
const track = await input.getPrimaryAudioTrack();
|
const track = await input.getPrimaryAudioTrack();
|
||||||
assert(track);
|
assert(track);
|
||||||
expect(await track.computeDuration()).toEqual(19.71428571428571);
|
expect(await track.computeDuration()).toEqual(19.714285714285715);
|
||||||
expect(await track.getDecoderConfig()).toEqual({
|
expect(await track.getDecoderConfig()).toEqual({
|
||||||
codec: 'flac',
|
codec: 'flac',
|
||||||
numberOfChannels: 2,
|
numberOfChannels: 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user