mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 16:53:47 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cacbc2a399 | ||
|
|
ab0fd6a8d8 | ||
|
|
6a099b4259 | ||
|
|
172b4a1fd2 | ||
|
|
43c1ea7efd | ||
|
|
cab92c55ec | ||
|
|
3209363470 |
@@ -506,6 +506,9 @@ type UrlSourceOptions = {
|
|||||||
// in memory. Defaults to 8 MiB.
|
// in memory. Defaults to 8 MiB.
|
||||||
maxCacheSize?: number;
|
maxCacheSize?: number;
|
||||||
|
|
||||||
|
// The maximum number of parallel requests to use for fetching. Defaults to 2.
|
||||||
|
parallelism?: number;
|
||||||
|
|
||||||
// Used to provide a custom fetch function
|
// Used to provide a custom fetch function
|
||||||
fetchFn?: typeof fetch;
|
fetchFn?: typeof fetch;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ const sponsors = {
|
|||||||
{ image: 'https://avatars.githubusercontent.com/u/84167135', name: 'Memenome', url: 'https://github.com/memenome' },
|
{ image: 'https://avatars.githubusercontent.com/u/84167135', name: 'Memenome', url: 'https://github.com/memenome' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/5913254', name: 'Brandon McConnell', url: 'https://github.com/brandonmcconnell' },
|
{ image: 'https://avatars.githubusercontent.com/u/5913254', name: 'Brandon McConnell', url: 'https://github.com/brandonmcconnell' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/9549394', name: 'studnitz', url: 'https://github.com/studnitz' },
|
{ image: 'https://avatars.githubusercontent.com/u/9549394', name: 'studnitz', url: 'https://github.com/studnitz' },
|
||||||
|
{ image: 'https://avatars.githubusercontent.com/u/4714175', name: 'Phoomparin Mano', url: 'https://github.com/heypoom' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/504909', name: 'Hirbod', url: 'https://github.com/hirbod' },
|
{ image: 'https://avatars.githubusercontent.com/u/504909', name: 'Hirbod', url: 'https://github.com/hirbod' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/2698271', name: 'Matthew Gardner', url: 'https://github.com/spheric' },
|
{ image: 'https://avatars.githubusercontent.com/u/2698271', name: 'Matthew Gardner', url: 'https://github.com/spheric' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/5475819', name: 'AJ Funk', url: 'https://github.com/AJFunk' },
|
{ image: 'https://avatars.githubusercontent.com/u/5475819', name: 'AJ Funk', url: 'https://github.com/AJFunk' },
|
||||||
@@ -122,6 +123,7 @@ const sponsors = {
|
|||||||
{ image: 'https://avatars.githubusercontent.com/u/38181164', name: 'wcw', url: 'https://github.com/asd55667' },
|
{ image: 'https://avatars.githubusercontent.com/u/38181164', name: 'wcw', url: 'https://github.com/asd55667' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/1836701', name: 'Bean Deng', url: 'https://github.com/HADB' },
|
{ image: 'https://avatars.githubusercontent.com/u/1836701', name: 'Bean Deng', url: 'https://github.com/HADB' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/255616819', name: 'cronischarles-del', url: 'https://github.com/cronischarles-del' },
|
{ image: 'https://avatars.githubusercontent.com/u/255616819', name: 'cronischarles-del', url: 'https://github.com/cronischarles-del' },
|
||||||
|
{ image: 'https://avatars.githubusercontent.com/u/37973863', name: 'Gomi', url: 'https://github.com/gxy5202' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/63088713', name: 'taf2000', url: 'https://github.com/taf2000' },
|
{ image: 'https://avatars.githubusercontent.com/u/63088713', name: 'taf2000', url: 'https://github.com/taf2000' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/58149663', name: 'H7GhosT', url: 'https://github.com/H7GhosT' },
|
{ image: 'https://avatars.githubusercontent.com/u/58149663', name: 'H7GhosT', url: 'https://github.com/H7GhosT' },
|
||||||
{ image: 'https://avatars.githubusercontent.com/u/91711202', name: 'ihasq', url: 'https://github.com/ihasq' },
|
{ image: 'https://avatars.githubusercontent.com/u/91711202', name: 'ihasq', url: 'https://github.com/ihasq' },
|
||||||
|
|||||||
Generated
+6
-6
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.31.1",
|
"version": "1.32.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.31.1",
|
"version": "1.32.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
@@ -7739,9 +7739,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mediabunny": {
|
"node_modules/mediabunny": {
|
||||||
"version": "1.31.0",
|
"version": "1.32.1",
|
||||||
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.31.0.tgz",
|
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.32.1.tgz",
|
||||||
"integrity": "sha512-nqM+6cOpNC/aDxCAZKnZe7oXnGaCn4rlgprzAmiH6C8GRdOHFnB6bZC0+WXGTT6mtAxXQd+BXuZ2q2zkma7dWg==",
|
"integrity": "sha512-pPxhBEIY7dNEhRarN/DTVL56RTce0iCwNwkhu/at+S9S/HKc01PpHs8oM2I+1I9ztQH/bo2zdyszxDuAwsEBAg==",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
@@ -12065,7 +12065,7 @@
|
|||||||
},
|
},
|
||||||
"packages/mp3-encoder": {
|
"packages/mp3-encoder": {
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"version": "1.31.1",
|
"version": "1.32.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.31.1",
|
"version": "1.32.2",
|
||||||
"description": "Pure TypeScript media toolkit for reading, writing, and converting media files, directly in the browser.",
|
"description": "Pure TypeScript media toolkit for reading, writing, and converting media files, directly in the browser.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.31.1",
|
"version": "1.32.2",
|
||||||
"description": "MP3 encoder extension for Mediabunny, based on LAME.",
|
"description": "MP3 encoder extension for Mediabunny, based on LAME.",
|
||||||
"main": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
"main": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
||||||
"module": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
"module": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
||||||
|
|||||||
+11
-3
@@ -343,6 +343,9 @@ export type UrlSourceOptions = {
|
|||||||
/** The maximum number of bytes the cache is allowed to hold in memory. Defaults to 64 MiB. */
|
/** The maximum number of bytes the cache is allowed to hold in memory. Defaults to 64 MiB. */
|
||||||
maxCacheSize?: number;
|
maxCacheSize?: number;
|
||||||
|
|
||||||
|
/** The maximum number of parallel requests to use for fetching. Defaults to 2. */
|
||||||
|
parallelism?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A WHATWG-compatible fetch function. You can use this field to polyfill the `fetch` function, add missing
|
* A WHATWG-compatible fetch function. You can use this field to polyfill the `fetch` function, add missing
|
||||||
* features, or use a custom implementation.
|
* features, or use a custom implementation.
|
||||||
@@ -403,6 +406,9 @@ export class UrlSource extends Source {
|
|||||||
) {
|
) {
|
||||||
throw new TypeError('options.maxCacheSize, when provided, must be a non-negative number.');
|
throw new TypeError('options.maxCacheSize, when provided, must be a non-negative number.');
|
||||||
}
|
}
|
||||||
|
if (options.parallelism !== undefined && (!Number.isInteger(options.parallelism) || options.parallelism < 1)) {
|
||||||
|
throw new TypeError('options.parallelism, when provided, must be a positive number.');
|
||||||
|
}
|
||||||
if (options.fetchFn !== undefined && typeof options.fetchFn !== 'function') {
|
if (options.fetchFn !== undefined && typeof options.fetchFn !== 'function') {
|
||||||
throw new TypeError('options.fetchFn, when provided, must be a function.');
|
throw new TypeError('options.fetchFn, when provided, must be a function.');
|
||||||
// Won't bother validating this function beyond this
|
// Won't bother validating this function beyond this
|
||||||
@@ -414,11 +420,13 @@ export class UrlSource extends Source {
|
|||||||
this._options = options;
|
this._options = options;
|
||||||
this._getRetryDelay = options.getRetryDelay ?? DEFAULT_RETRY_DELAY;
|
this._getRetryDelay = options.getRetryDelay ?? DEFAULT_RETRY_DELAY;
|
||||||
|
|
||||||
|
// Most files in the real-world have a single sequential access pattern, but having two in parallel can
|
||||||
|
// also happen
|
||||||
|
const DEFAULT_PARALLELISM = 2;
|
||||||
|
|
||||||
this._orchestrator = new ReadOrchestrator({
|
this._orchestrator = new ReadOrchestrator({
|
||||||
maxCacheSize: options.maxCacheSize ?? (64 * 2 ** 20 /* 64 MiB */),
|
maxCacheSize: options.maxCacheSize ?? (64 * 2 ** 20 /* 64 MiB */),
|
||||||
// Most files in the real-world have a single sequential access pattern, but having two in parallel can
|
maxWorkerCount: options.parallelism ?? DEFAULT_PARALLELISM,
|
||||||
// also happen
|
|
||||||
maxWorkerCount: 2,
|
|
||||||
runWorker: this._runWorker.bind(this),
|
runWorker: this._runWorker.bind(this),
|
||||||
prefetchProfile: PREFETCH_PROFILES.network,
|
prefetchProfile: PREFETCH_PROFILES.network,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -425,6 +425,8 @@ class WaveAudioTrackBacking implements InputAudioTrackBacking {
|
|||||||
packetIndex: number,
|
packetIndex: number,
|
||||||
options: PacketRetrievalOptions,
|
options: PacketRetrievalOptions,
|
||||||
): Promise<EncodedPacket | null> {
|
): Promise<EncodedPacket | null> {
|
||||||
|
assert(packetIndex >= 0);
|
||||||
|
|
||||||
assert(this.demuxer.audioInfo);
|
assert(this.demuxer.audioInfo);
|
||||||
const startOffset = packetIndex * PACKET_SIZE_IN_FRAMES * this.demuxer.audioInfo.blockSizeInBytes;
|
const startOffset = packetIndex * PACKET_SIZE_IN_FRAMES * this.demuxer.audioInfo.blockSizeInBytes;
|
||||||
if (startOffset >= this.demuxer.dataSize) {
|
if (startOffset >= this.demuxer.dataSize) {
|
||||||
@@ -465,7 +467,7 @@ class WaveAudioTrackBacking implements InputAudioTrackBacking {
|
|||||||
|
|
||||||
this.demuxer.lastKnownPacketIndex = Math.max(
|
this.demuxer.lastKnownPacketIndex = Math.max(
|
||||||
packetIndex,
|
packetIndex,
|
||||||
timestamp,
|
this.demuxer.lastKnownPacketIndex,
|
||||||
);
|
);
|
||||||
|
|
||||||
return new EncodedPacket(
|
return new EncodedPacket(
|
||||||
@@ -489,6 +491,9 @@ class WaveAudioTrackBacking implements InputAudioTrackBacking {
|
|||||||
timestamp * this.demuxer.audioInfo.sampleRate / PACKET_SIZE_IN_FRAMES,
|
timestamp * this.demuxer.audioInfo.sampleRate / PACKET_SIZE_IN_FRAMES,
|
||||||
(this.demuxer.dataSize - 1) / (PACKET_SIZE_IN_FRAMES * this.demuxer.audioInfo.blockSizeInBytes),
|
(this.demuxer.dataSize - 1) / (PACKET_SIZE_IN_FRAMES * this.demuxer.audioInfo.blockSizeInBytes),
|
||||||
));
|
));
|
||||||
|
if (packetIndex < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const packet = await this.getPacketAtIndex(packetIndex, options);
|
const packet = await this.getPacketAtIndex(packetIndex, options);
|
||||||
if (packet) {
|
if (packet) {
|
||||||
|
|||||||
Reference in New Issue
Block a user