mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-10 09:13:47 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f8770de99 | ||
|
|
c498b87b3e | ||
|
|
ffdaf2dacb | ||
|
|
448e43cbfc | ||
|
|
ef2094b0db | ||
|
|
daa6bdbe1d | ||
|
|
2d11f53192 | ||
|
|
1b4628cbb0 | ||
|
|
72eb54391e |
@@ -1,4 +1,3 @@
|
|||||||
.vscode
|
|
||||||
node_modules
|
node_modules
|
||||||
/dist
|
/dist
|
||||||
/dist-docs
|
/dist-docs
|
||||||
|
|||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||||
|
}
|
||||||
Generated
+6
-6
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.11.0",
|
"version": "1.11.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.11.0",
|
"version": "1.11.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
@@ -5900,9 +5900,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mediabunny": {
|
"node_modules/mediabunny": {
|
||||||
"version": "1.10.0",
|
"version": "1.11.1",
|
||||||
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.11.1.tgz",
|
||||||
"integrity": "sha512-M2Fe9jZJ1VEjp8i7CmwBY38UDiA3V0qWIv1hbFBfL8rh27ZVQyL9f1u3FtrerlpaKT0Q+c1LHjcjVmhwp9N5kA==",
|
"integrity": "sha512-UsoLZi9aHcQWMHsQF0Y4xSREy2eByFvHRjK3kmvfuaYDHPiqsj0tN6HE+daSzr+WHUh98pFlu2XKXwzBp2AHcQ==",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
@@ -9017,7 +9017,7 @@
|
|||||||
},
|
},
|
||||||
"packages/mp3-encoder": {
|
"packages/mp3-encoder": {
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"version": "1.11.0",
|
"version": "1.11.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.11.0",
|
"version": "1.11.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.11.0",
|
"version": "1.11.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",
|
||||||
|
|||||||
+50
-40
@@ -37,10 +37,55 @@ import {
|
|||||||
VideoSampleSource,
|
VideoSampleSource,
|
||||||
AudioSampleSource,
|
AudioSampleSource,
|
||||||
} from './media-source';
|
} from './media-source';
|
||||||
import { assert, clamp, MaybePromise, normalizeRotation, promiseWithResolvers, Rotation } from './misc';
|
import {
|
||||||
|
assert,
|
||||||
|
clamp,
|
||||||
|
isIso639Dash2LanguageCode,
|
||||||
|
MaybePromise,
|
||||||
|
normalizeRotation,
|
||||||
|
promiseWithResolvers,
|
||||||
|
Rotation,
|
||||||
|
} from './misc';
|
||||||
import { Output, TrackType } from './output';
|
import { Output, TrackType } from './output';
|
||||||
import { AudioSample, VideoSample } from './sample';
|
import { AudioSample, VideoSample } from './sample';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The options for media file conversion.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export type ConversionOptions = {
|
||||||
|
/** The input file. */
|
||||||
|
input: Input;
|
||||||
|
/** The output file. */
|
||||||
|
output: Output;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Video-specific options. When passing an object, the same options are applied to all video tracks. When passing a
|
||||||
|
* function, it will be invoked for each video track and is expected to return or resolve to the options
|
||||||
|
* for that specific track. The function is passed an instance of `InputVideoTrack` as well as a number `n`, which
|
||||||
|
* is the 1-based index of the track in the list of all video tracks.
|
||||||
|
*/
|
||||||
|
video?: ConversionVideoOptions
|
||||||
|
| ((track: InputVideoTrack, n: number) => MaybePromise<ConversionVideoOptions | undefined>);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Audio-specific options. When passing an object, the same options are applied to all audio tracks. When passing a
|
||||||
|
* function, it will be invoked for each audio track and is expected to return or resolve to the options
|
||||||
|
* for that specific track. The function is passed an instance of `InputAudioTrack` as well as a number `n`, which
|
||||||
|
* is the 1-based index of the track in the list of all audio tracks.
|
||||||
|
*/
|
||||||
|
audio?: ConversionAudioOptions
|
||||||
|
| ((track: InputAudioTrack, n: number) => MaybePromise<ConversionAudioOptions | undefined>);
|
||||||
|
|
||||||
|
/** Options to trim the input file. */
|
||||||
|
trim?: {
|
||||||
|
/** The time in the input file in seconds at which the output file should start. Must be less than `end`. */
|
||||||
|
start: number;
|
||||||
|
/** The time in the input file in seconds at which the output file should end. Must be greater than `start`. */
|
||||||
|
end: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Video-specific options.
|
* Video-specific options.
|
||||||
* @public
|
* @public
|
||||||
@@ -162,43 +207,6 @@ const validateVideoOptions = (videoOptions: ConversionVideoOptions | undefined)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* The options for media file conversion.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export type ConversionOptions = {
|
|
||||||
/** The input file. */
|
|
||||||
input: Input;
|
|
||||||
/** The output file. */
|
|
||||||
output: Output;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Video-specific options. When passing an object, the same options are applied to all video tracks. When passing a
|
|
||||||
* function, it will be invoked for each video track and is expected to return or resolve to the options
|
|
||||||
* for that specific track. The function is passed an instance of `InputVideoTrack` as well as a number `n`, which
|
|
||||||
* is the 1-based index of the track in the list of all video tracks.
|
|
||||||
*/
|
|
||||||
video?: ConversionVideoOptions
|
|
||||||
| ((track: InputVideoTrack, n: number) => MaybePromise<ConversionVideoOptions | undefined>);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Audio-specific options. When passing an object, the same options are applied to all audio tracks. When passing a
|
|
||||||
* function, it will be invoked for each audio track and is expected to return or resolve to the options
|
|
||||||
* for that specific track. The function is passed an instance of `InputAudioTrack` as well as a number `n`, which
|
|
||||||
* is the 1-based index of the track in the list of all audio tracks.
|
|
||||||
*/
|
|
||||||
audio?: ConversionAudioOptions
|
|
||||||
| ((track: InputAudioTrack, n: number) => MaybePromise<ConversionAudioOptions | undefined>);
|
|
||||||
|
|
||||||
/** Options to trim the input file. */
|
|
||||||
trim?: {
|
|
||||||
/** The time in the input file in seconds at which the output file should start. Must be less than `end`. */
|
|
||||||
start: number;
|
|
||||||
/** The time in the input file in seconds at which the output file should end. Must be greater than `start`. */
|
|
||||||
end: number;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const validateAudioOptions = (audioOptions: ConversionAudioOptions | undefined) => {
|
const validateAudioOptions = (audioOptions: ConversionAudioOptions | undefined) => {
|
||||||
if (audioOptions !== undefined && (!audioOptions || typeof audioOptions !== 'object')) {
|
if (audioOptions !== undefined && (!audioOptions || typeof audioOptions !== 'object')) {
|
||||||
throw new TypeError('options.audio, when provided, must be an object.');
|
throw new TypeError('options.audio, when provided, must be an object.');
|
||||||
@@ -811,7 +819,8 @@ export class Conversion {
|
|||||||
|
|
||||||
this.output.addVideoTrack(videoSource, {
|
this.output.addVideoTrack(videoSource, {
|
||||||
frameRate: trackOptions.frameRate,
|
frameRate: trackOptions.frameRate,
|
||||||
languageCode: track.languageCode,
|
// TEMP: This condition can be removed when all demuxers properly homogenize to BCP47 in v2
|
||||||
|
languageCode: isIso639Dash2LanguageCode(track.languageCode) ? track.languageCode : undefined,
|
||||||
name: track.name ?? undefined,
|
name: track.name ?? undefined,
|
||||||
rotation: needsRerender ? 0 : totalRotation, // Rerendering will bake the rotation into the output
|
rotation: needsRerender ? 0 : totalRotation, // Rerendering will bake the rotation into the output
|
||||||
});
|
});
|
||||||
@@ -981,7 +990,8 @@ export class Conversion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.output.addAudioTrack(audioSource, {
|
this.output.addAudioTrack(audioSource, {
|
||||||
languageCode: track.languageCode,
|
// TEMP: This condition can be removed when all demuxers properly homogenize to BCP47 in v2
|
||||||
|
languageCode: isIso639Dash2LanguageCode(track.languageCode) ? track.languageCode : undefined,
|
||||||
name: track.name ?? undefined,
|
name: track.name ?? undefined,
|
||||||
});
|
});
|
||||||
this._addedCounts.audio++;
|
this._addedCounts.audio++;
|
||||||
|
|||||||
@@ -1014,7 +1014,10 @@ export class MatroskaDemuxer extends Demuxer {
|
|||||||
|
|
||||||
case EBMLId.Language: {
|
case EBMLId.Language: {
|
||||||
if (!this.currentTrack) break;
|
if (!this.currentTrack) break;
|
||||||
if (this.currentTrack.languageCode) break; // LanguageBCP47 was present, which takes precedence
|
if (this.currentTrack.languageCode !== UNDETERMINED_LANGUAGE) {
|
||||||
|
// LanguageBCP47 was present, which takes precedence
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
this.currentTrack.languageCode = reader.readAsciiString(size);
|
this.currentTrack.languageCode = reader.readAsciiString(size);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user