mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 16:53:47 +02:00
Merge main into release for tag v1.52.3
This commit is contained in:
@@ -130,7 +130,7 @@ const { title, artist, album } = await input.getMetadataTags();
|
|||||||
### Create new media files
|
### Create new media files
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { Output, Mp4OutputFormat, BufferTarget, CanvasSource, QUALITY_HIGH } from 'mediabunny';
|
import { Output, Mp4OutputFormat, BufferTarget, CanvasSource, Quality } from 'mediabunny';
|
||||||
|
|
||||||
const output = new Output({
|
const output = new Output({
|
||||||
format: new Mp4OutputFormat(),
|
format: new Mp4OutputFormat(),
|
||||||
@@ -140,7 +140,7 @@ const output = new Output({
|
|||||||
// Add a video track backed by a canvas element
|
// Add a video track backed by a canvas element
|
||||||
const videoSource = new CanvasSource(canvas, {
|
const videoSource = new CanvasSource(canvas, {
|
||||||
codec: 'avc',
|
codec: 'avc',
|
||||||
bitrate: QUALITY_HIGH,
|
bitrate: new Quality('high'),
|
||||||
});
|
});
|
||||||
output.addVideoTrack(videoSource);
|
output.addVideoTrack(videoSource);
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -47,7 +47,7 @@
|
|||||||
format = new Mediabunny.MkvOutputFormat();
|
format = new Mediabunny.MkvOutputFormat();
|
||||||
format = new Mediabunny.MovOutputFormat();
|
format = new Mediabunny.MovOutputFormat();
|
||||||
format = new Mediabunny.Mp4OutputFormat({ fastStart: 'reserve' });
|
format = new Mediabunny.Mp4OutputFormat({ fastStart: 'reserve' });
|
||||||
format = new Mediabunny.WebMOutputFormat();
|
format = new Mediabunny.Mp4OutputFormat();
|
||||||
let target = new Mediabunny.BufferTarget();
|
let target = new Mediabunny.BufferTarget();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -118,21 +118,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
let videoSource = new Mediabunny.CanvasSource(canvas, {
|
let videoSource = new Mediabunny.CanvasSource(canvas, {
|
||||||
codec: 'vp9',
|
codec: 'avc',
|
||||||
//fullCodecString: 'avc1.42001f',
|
//fullCodecString: 'avc1.42001f',
|
||||||
bitrate: 1e6,
|
bitrate: 1e6,
|
||||||
alpha: 'keep',
|
alpha: 'keep',
|
||||||
onEncoderConfig: console.log,
|
onEncoderConfig: console.log,
|
||||||
});
|
});
|
||||||
let audioSource = new Mediabunny.AudioBufferSource({
|
let audioSource = new Mediabunny.AudioBufferSource({
|
||||||
codec: 'opus',
|
codec: 'aac',
|
||||||
bitrate: 128e3,
|
bitrate: 128e3,
|
||||||
});
|
});
|
||||||
let subtitleSource = new Mediabunny.TextSubtitleSource('webvtt');
|
let subtitleSource = new Mediabunny.TextSubtitleSource('webvtt');
|
||||||
|
|
||||||
output.addVideoTrack(videoSource, { languageCode: 'eng', name: 'Mononoké', maximumPacketCount: 100 });
|
output.addVideoTrack(videoSource, { languageCode: 'eng', name: 'Mononoké', maximumPacketCount: 100 });
|
||||||
output.addAudioTrack(audioSource, { name: 'Yooo', maximumPacketCount: 1000 });
|
output.addAudioTrack(audioSource, { name: 'Yooo', maximumPacketCount: 1000 });
|
||||||
//output.addSubtitleTrack(subtitleSource);
|
output.addSubtitleTrack(subtitleSource);
|
||||||
|
|
||||||
output.start();
|
output.start();
|
||||||
|
|
||||||
@@ -191,8 +191,8 @@ Testing... <00:17.350>One... <00:18.125>Two...
|
|||||||
9. <b>justify (bottom, right)</b>.
|
9. <b>justify (bottom, right)</b>.
|
||||||
`;
|
`;
|
||||||
|
|
||||||
//subtitleSource.add(simpleWebvttFile);
|
subtitleSource.add(simpleWebvttFile);
|
||||||
//subtitleSource.close();
|
subtitleSource.close();
|
||||||
|
|
||||||
const p = document.createElement('p');
|
const p = document.createElement('p');
|
||||||
document.body.append(p);
|
document.body.append(p);
|
||||||
@@ -216,5 +216,5 @@ Testing... <00:17.350>One... <00:18.125>Two...
|
|||||||
await output.finalize();
|
await output.finalize();
|
||||||
|
|
||||||
console.log(target);
|
console.log(target);
|
||||||
//download(new Blob([target.buffer]), 'test' + format.fileExtension);
|
download(new Blob([target.buffer]), 'test' + format.fileExtension);
|
||||||
</script>
|
</script>
|
||||||
Generated
+9
-9
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
".",
|
".",
|
||||||
@@ -12954,7 +12954,7 @@
|
|||||||
},
|
},
|
||||||
"packages/aac-encoder": {
|
"packages/aac-encoder": {
|
||||||
"name": "@mediabunny/aac-encoder",
|
"name": "@mediabunny/aac-encoder",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
@@ -12969,7 +12969,7 @@
|
|||||||
},
|
},
|
||||||
"packages/ac3": {
|
"packages/ac3": {
|
||||||
"name": "@mediabunny/ac3",
|
"name": "@mediabunny/ac3",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
@@ -12984,7 +12984,7 @@
|
|||||||
},
|
},
|
||||||
"packages/flac-encoder": {
|
"packages/flac-encoder": {
|
||||||
"name": "@mediabunny/flac-encoder",
|
"name": "@mediabunny/flac-encoder",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
@@ -12999,7 +12999,7 @@
|
|||||||
},
|
},
|
||||||
"packages/mp3-encoder": {
|
"packages/mp3-encoder": {
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
@@ -13014,7 +13014,7 @@
|
|||||||
},
|
},
|
||||||
"packages/prores": {
|
"packages/prores": {
|
||||||
"name": "@mediabunny/prores",
|
"name": "@mediabunny/prores",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"turbores": "^1.2.2"
|
"turbores": "^1.2.2"
|
||||||
@@ -13029,10 +13029,10 @@
|
|||||||
},
|
},
|
||||||
"packages/server": {
|
"packages/server": {
|
||||||
"name": "@mediabunny/server",
|
"name": "@mediabunny/server",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mediabunny/prores": "^1.52.2",
|
"@mediabunny/prores": "^1.52.3",
|
||||||
"node-av": "^6.0.0"
|
"node-av": "^6.0.0"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"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/aac-encoder",
|
"name": "@mediabunny/aac-encoder",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"description": "AAC encoder extension for Mediabunny, based on FFmpeg.",
|
"description": "AAC encoder extension for Mediabunny, based on FFmpeg.",
|
||||||
"main": "./dist/bundles/mediabunny-aac-encoder.mjs",
|
"main": "./dist/bundles/mediabunny-aac-encoder.mjs",
|
||||||
"module": "./dist/bundles/mediabunny-aac-encoder.mjs",
|
"module": "./dist/bundles/mediabunny-aac-encoder.mjs",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@mediabunny/ac3",
|
"name": "@mediabunny/ac3",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"description": "AC-3 and E-AC-3 (Dolby Digital) decoder and encoder extension for Mediabunny, based on FFmpeg.",
|
"description": "AC-3 and E-AC-3 (Dolby Digital) decoder and encoder extension for Mediabunny, based on FFmpeg.",
|
||||||
"main": "./dist/bundles/mediabunny-ac3.mjs",
|
"main": "./dist/bundles/mediabunny-ac3.mjs",
|
||||||
"module": "./dist/bundles/mediabunny-ac3.mjs",
|
"module": "./dist/bundles/mediabunny-ac3.mjs",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@mediabunny/flac-encoder",
|
"name": "@mediabunny/flac-encoder",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"description": "FLAC encoder extension for Mediabunny, based on libFLAC.",
|
"description": "FLAC encoder extension for Mediabunny, based on libFLAC.",
|
||||||
"main": "./dist/bundles/mediabunny-flac-encoder.mjs",
|
"main": "./dist/bundles/mediabunny-flac-encoder.mjs",
|
||||||
"module": "./dist/bundles/mediabunny-flac-encoder.mjs",
|
"module": "./dist/bundles/mediabunny-flac-encoder.mjs",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@mediabunny/prores",
|
"name": "@mediabunny/prores",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"description": "Apple ProRes decoder extension for Mediabunny, based on TurboRes.",
|
"description": "Apple ProRes decoder extension for Mediabunny, based on TurboRes.",
|
||||||
"main": "./dist/bundles/mediabunny-prores.mjs",
|
"main": "./dist/bundles/mediabunny-prores.mjs",
|
||||||
"module": "./dist/bundles/mediabunny-prores.mjs",
|
"module": "./dist/bundles/mediabunny-prores.mjs",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@mediabunny/server",
|
"name": "@mediabunny/server",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.52.2",
|
"version": "1.52.3",
|
||||||
"description": "Adds full video and audio decoder and encoder support to Mediabunny for use in server-side environments (Node, Bun, Deno). Based on NodeAV.",
|
"description": "Adds full video and audio decoder and encoder support to Mediabunny for use in server-side environments (Node, Bun, Deno). Based on NodeAV.",
|
||||||
"main": "./dist/bundles/mediabunny-server.cjs",
|
"main": "./dist/bundles/mediabunny-server.cjs",
|
||||||
"module": "./dist/bundles/mediabunny-server.mjs",
|
"module": "./dist/bundles/mediabunny-server.mjs",
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-av": "^6.0.0",
|
"node-av": "^6.0.0",
|
||||||
"@mediabunny/prores": "^1.52.2"
|
"@mediabunny/prores": "^1.52.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"mediabunny": "^1.45.0"
|
"mediabunny": "^1.45.0"
|
||||||
|
|||||||
@@ -493,6 +493,17 @@ export const tkhd = (
|
|||||||
flags |= 0x1; // Track enabled
|
flags |= 0x1; // Track enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the alternate group based on the track type; this mirror's how FFmpeg does it. A more advanced version would
|
||||||
|
// determine the alternate groups based on the actual track pairability graph. Note that it appears important that
|
||||||
|
// video get assigned to group 0, see https://github.com/Vanilagy/mediabunny/issues/454.
|
||||||
|
const alternateGroup = trackData.type === 'video'
|
||||||
|
? 0
|
||||||
|
: trackData.type === 'audio'
|
||||||
|
? 1
|
||||||
|
: trackData.type === 'subtitle'
|
||||||
|
? 2
|
||||||
|
: assertNever(trackData);
|
||||||
|
|
||||||
return fullBox('tkhd', +needsU64, flags, [
|
return fullBox('tkhd', +needsU64, flags, [
|
||||||
u32OrU64(creationTime), // Creation time
|
u32OrU64(creationTime), // Creation time
|
||||||
u32OrU64(creationTime), // Modification time
|
u32OrU64(creationTime), // Modification time
|
||||||
@@ -501,7 +512,7 @@ export const tkhd = (
|
|||||||
u32OrU64(durationInGlobalTimescale), // Duration
|
u32OrU64(durationInGlobalTimescale), // Duration
|
||||||
Array(8).fill(0), // Reserved
|
Array(8).fill(0), // Reserved
|
||||||
u16(0), // Layer
|
u16(0), // Layer
|
||||||
u16(trackData.track.id), // Alternate group
|
u16(alternateGroup), // Alternate group
|
||||||
fixed_8_8(trackData.type === 'audio' ? 1 : 0), // Volume
|
fixed_8_8(trackData.type === 'audio' ? 1 : 0), // Volume
|
||||||
u16(0), // Reserved
|
u16(0), // Reserved
|
||||||
matrixToBytes(matrix), // Matrix
|
matrixToBytes(matrix), // Matrix
|
||||||
|
|||||||
+3
-2
@@ -830,7 +830,8 @@ export class Output<
|
|||||||
return this._startPromise = (async () => {
|
return this._startPromise = (async () => {
|
||||||
this.state = 'started';
|
this.state = 'started';
|
||||||
|
|
||||||
const release = await this._mutex.acquire();
|
// We want to call muxer.start immediately, so we avoid using an await here
|
||||||
|
const releasePromise = this._mutex.acquire();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this._muxer.start();
|
await this._muxer.start();
|
||||||
@@ -838,7 +839,7 @@ export class Output<
|
|||||||
const promises = this.tracks.map(track => track.source._start());
|
const promises = this.tracks.map(track => track.source._start());
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
} finally {
|
} finally {
|
||||||
release();
|
(await releasePromise)();
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user