Compare commits

..
9 Commits
Author SHA1 Message Date
Vanilagy 7f8770de99 Fix regular Language element in Matroska not having an effect anymore 2025-08-27 08:56:41 +02:00
David P.andGitHub c498b87b3e Merge pull request #76 from JonnyBurger/align-prettier-style
Instruct VSCode to use ESLint as default formatter
2025-08-26 16:30:21 +02:00
Jonny BurgerandGitHub ffdaf2dacb Discard changes to package.json 2025-08-26 15:10:27 +02:00
JonnyBurger 448e43cbfc Instruct .vscode to use ESLint as a default formatter 2025-08-26 15:10:13 +02:00
JonnyBurger ef2094b0db Add trailing-comma option 2025-08-26 15:07:12 +02:00
JonnyBurger daa6bdbe1d Match Prettier style
This way, people who have Prettier as their default formatter in their Editor (probably the majority of people) will not have the code re-formatted to double quotes if they are saving
2025-08-26 15:03:54 +02:00
Vanilagy 2d11f53192 Oops 2025-08-25 19:57:25 +02:00
Vanilagy 1b4628cbb0 Add temp conversion fix regarding languageCode 2025-08-25 19:45:02 +02:00
Vanilagy 72eb54391e Reorder 2025-08-24 18:10:35 +02:00
7 changed files with 65 additions and 50 deletions
-1
View File
@@ -1,4 +1,3 @@
.vscode
node_modules
/dist
/dist-docs
+3
View File
@@ -0,0 +1,3 @@
{
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
+6 -6
View File
@@ -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
View File
@@ -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 -1
View File
@@ -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
View File
@@ -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++;
+4 -1
View File
@@ -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);