mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-08 00:03:58 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f8770de99 | ||
|
|
c498b87b3e | ||
|
|
ffdaf2dacb | ||
|
|
448e43cbfc | ||
|
|
ef2094b0db | ||
|
|
daa6bdbe1d | ||
|
|
2d11f53192 | ||
|
|
1b4628cbb0 | ||
|
|
72eb54391e |
@@ -1,4 +1,3 @@
|
||||
.vscode
|
||||
node_modules
|
||||
/dist
|
||||
/dist-docs
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||
}
|
||||
Generated
+6
-6
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "mediabunny",
|
||||
"version": "1.11.0",
|
||||
"version": "1.11.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mediabunny",
|
||||
"version": "1.11.0",
|
||||
"version": "1.11.2",
|
||||
"license": "MPL-2.0",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
@@ -5900,9 +5900,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/mediabunny": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.10.0.tgz",
|
||||
"integrity": "sha512-M2Fe9jZJ1VEjp8i7CmwBY38UDiA3V0qWIv1hbFBfL8rh27ZVQyL9f1u3FtrerlpaKT0Q+c1LHjcjVmhwp9N5kA==",
|
||||
"version": "1.11.1",
|
||||
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.11.1.tgz",
|
||||
"integrity": "sha512-UsoLZi9aHcQWMHsQF0Y4xSREy2eByFvHRjK3kmvfuaYDHPiqsj0tN6HE+daSzr+WHUh98pFlu2XKXwzBp2AHcQ==",
|
||||
"license": "MPL-2.0",
|
||||
"peer": true,
|
||||
"workspaces": [
|
||||
@@ -9017,7 +9017,7 @@
|
||||
},
|
||||
"packages/mp3-encoder": {
|
||||
"name": "@mediabunny/mp3-encoder",
|
||||
"version": "1.11.0",
|
||||
"version": "1.11.2",
|
||||
"license": "MPL-2.0",
|
||||
"devDependencies": {
|
||||
"@types/emscripten": "^1.40.1"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "mediabunny",
|
||||
"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.",
|
||||
"type": "module",
|
||||
"workspaces": [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@mediabunny/mp3-encoder",
|
||||
"author": "Vanilagy",
|
||||
"version": "1.11.0",
|
||||
"version": "1.11.2",
|
||||
"description": "MP3 encoder extension for Mediabunny, based on LAME.",
|
||||
"main": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
||||
"module": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
||||
|
||||
+50
-40
@@ -37,10 +37,55 @@ import {
|
||||
VideoSampleSource,
|
||||
AudioSampleSource,
|
||||
} 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 { 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.
|
||||
* @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) => {
|
||||
if (audioOptions !== undefined && (!audioOptions || typeof audioOptions !== 'object')) {
|
||||
throw new TypeError('options.audio, when provided, must be an object.');
|
||||
@@ -811,7 +819,8 @@ export class Conversion {
|
||||
|
||||
this.output.addVideoTrack(videoSource, {
|
||||
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,
|
||||
rotation: needsRerender ? 0 : totalRotation, // Rerendering will bake the rotation into the output
|
||||
});
|
||||
@@ -981,7 +990,8 @@ export class Conversion {
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
this._addedCounts.audio++;
|
||||
|
||||
@@ -1014,7 +1014,10 @@ export class MatroskaDemuxer extends Demuxer {
|
||||
|
||||
case EBMLId.Language: {
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user