mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-03 13:53:53 +02:00
Merge main into release for tag v1.44.2
This commit is contained in:
+6
-3
@@ -96,7 +96,8 @@
|
|||||||
input,
|
input,
|
||||||
output,
|
output,
|
||||||
audio: {
|
audio: {
|
||||||
discard: true,
|
codec: 'aac',
|
||||||
|
forceTranscode: true,
|
||||||
//forceTranscode: true,
|
//forceTranscode: true,
|
||||||
//sampleFormat: 's16',
|
//sampleFormat: 's16',
|
||||||
},
|
},
|
||||||
@@ -125,7 +126,7 @@
|
|||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
video: {
|
video: {
|
||||||
//discard: true,
|
discard: true,
|
||||||
},
|
},
|
||||||
tags: {} ?? {
|
tags: {} ?? {
|
||||||
title: 'Bigggy',
|
title: 'Bigggy',
|
||||||
@@ -145,7 +146,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
trim: {
|
trim: {
|
||||||
end: 10,
|
start: 300.14984567374756 - 100,
|
||||||
|
end: 310.1548298151939 - 100,
|
||||||
|
//end: 10,
|
||||||
//start: startTime,
|
//start: startTime,
|
||||||
//end: startTime + 2,
|
//end: startTime + 2,
|
||||||
},
|
},
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.44.1",
|
"version": "1.44.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.44.1",
|
"version": "1.44.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.44.1",
|
"version": "1.44.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/aac-encoder",
|
"name": "@mediabunny/aac-encoder",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.44.1",
|
"version": "1.44.2",
|
||||||
"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.44.1",
|
"version": "1.44.2",
|
||||||
"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.44.1",
|
"version": "1.44.2",
|
||||||
"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.44.1",
|
"version": "1.44.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",
|
||||||
|
|||||||
@@ -1889,6 +1889,7 @@ export class Conversion {
|
|||||||
startTime: this._startTimestamp,
|
startTime: this._startTimestamp,
|
||||||
endTime: this._endTimestamp,
|
endTime: this._endTimestamp,
|
||||||
onSample: async (sample) => {
|
onSample: async (sample) => {
|
||||||
|
assert(sample.timestamp >= this._startTimestamp);
|
||||||
sample.setTimestamp(sample.timestamp - this._startTimestamp);
|
sample.setTimestamp(sample.timestamp - this._startTimestamp);
|
||||||
|
|
||||||
await this._registerAudioSample(trackOptions, outputTrackId, source, sample);
|
await this._registerAudioSample(trackOptions, outputTrackId, source, sample);
|
||||||
|
|||||||
+7
-4
@@ -20,7 +20,6 @@ export class AudioResampler {
|
|||||||
targetSampleRate: number;
|
targetSampleRate: number;
|
||||||
sourceNumberOfChannels: number | null = null;
|
sourceNumberOfChannels: number | null = null;
|
||||||
targetNumberOfChannels: number;
|
targetNumberOfChannels: number;
|
||||||
startTime: number;
|
|
||||||
endTime: number;
|
endTime: number;
|
||||||
onSample: (sample: AudioSample) => Promise<void>;
|
onSample: (sample: AudioSample) => Promise<void>;
|
||||||
|
|
||||||
@@ -33,6 +32,7 @@ export class AudioResampler {
|
|||||||
maxWrittenFrame: number | null = null;
|
maxWrittenFrame: number | null = null;
|
||||||
channelMixer!: (sourceData: Float32Array, sourceFrameIndex: number, targetChannelIndex: number) => number;
|
channelMixer!: (sourceData: Float32Array, sourceFrameIndex: number, targetChannelIndex: number) => number;
|
||||||
tempSourceBuffer!: Float32Array;
|
tempSourceBuffer!: Float32Array;
|
||||||
|
timestampOffset: number;
|
||||||
|
|
||||||
constructor(options: {
|
constructor(options: {
|
||||||
targetSampleRate: number;
|
targetSampleRate: number;
|
||||||
@@ -43,7 +43,6 @@ export class AudioResampler {
|
|||||||
}) {
|
}) {
|
||||||
this.targetSampleRate = options.targetSampleRate;
|
this.targetSampleRate = options.targetSampleRate;
|
||||||
this.targetNumberOfChannels = options.targetNumberOfChannels;
|
this.targetNumberOfChannels = options.targetNumberOfChannels;
|
||||||
this.startTime = options.startTime;
|
|
||||||
this.endTime = options.endTime;
|
this.endTime = options.endTime;
|
||||||
this.onSample = options.onSample;
|
this.onSample = options.onSample;
|
||||||
|
|
||||||
@@ -51,7 +50,11 @@ export class AudioResampler {
|
|||||||
this.bufferSizeInSamples = this.bufferSizeInFrames * this.targetNumberOfChannels;
|
this.bufferSizeInSamples = this.bufferSizeInFrames * this.targetNumberOfChannels;
|
||||||
|
|
||||||
this.outputBuffer = new Float32Array(this.bufferSizeInSamples);
|
this.outputBuffer = new Float32Array(this.bufferSizeInSamples);
|
||||||
this.bufferStartFrame = Math.floor(this.startTime * this.targetSampleRate);
|
|
||||||
|
this.bufferStartFrame = Math.floor(options.startTime * this.targetSampleRate);
|
||||||
|
// Set to ensure that if the buffer start frame lands on a fractional sample, that the first timestamp still
|
||||||
|
// comes out as exactly startTime
|
||||||
|
this.timestampOffset = options.startTime - this.bufferStartFrame / this.targetSampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,7 +276,7 @@ export class AudioResampler {
|
|||||||
format: 'f32',
|
format: 'f32',
|
||||||
sampleRate: this.targetSampleRate,
|
sampleRate: this.targetSampleRate,
|
||||||
numberOfChannels: this.targetNumberOfChannels,
|
numberOfChannels: this.targetNumberOfChannels,
|
||||||
timestamp: timestampSeconds,
|
timestamp: timestampSeconds + this.timestampOffset,
|
||||||
data: outputData,
|
data: outputData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
import { ALL_FORMATS } from '../../src/input-format.js';
|
import { ALL_FORMATS } from '../../src/input-format.js';
|
||||||
import { Input } from '../../src/input.js';
|
import { Input } from '../../src/input.js';
|
||||||
import { AdtsOutputFormat, HlsOutputFormat, Mp4OutputFormat, MpegTsOutputFormat } from '../../src/output-format.js';
|
import {
|
||||||
|
AdtsOutputFormat,
|
||||||
|
HlsOutputFormat,
|
||||||
|
Mp4OutputFormat,
|
||||||
|
MpegTsOutputFormat,
|
||||||
|
WavOutputFormat,
|
||||||
|
} from '../../src/output-format.js';
|
||||||
import { Output, OutputTrackGroup } from '../../src/output.js';
|
import { Output, OutputTrackGroup } from '../../src/output.js';
|
||||||
import { BufferSource, CustomPathedSource, UrlSource } from '../../src/source.js';
|
import { BufferSource, CustomPathedSource, UrlSource } from '../../src/source.js';
|
||||||
import { expect, test } from 'vitest';
|
import { expect, test } from 'vitest';
|
||||||
@@ -369,3 +375,30 @@ test('HLS track assignability can be overridden', async () => {
|
|||||||
expect(newMasterPlayist).not.toBe(masterPlayist);
|
expect(newMasterPlayist).not.toBe(masterPlayist);
|
||||||
expect(newMasterPlayist.match(/\.m3u8/g)?.length).toBe(1);
|
expect(newMasterPlayist.match(/\.m3u8/g)?.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Fractional audio sample boundary', async () => {
|
||||||
|
using input = new Input({
|
||||||
|
source: new UrlSource('/trim-buck-bunny-ffmpeg.ts'),
|
||||||
|
formats: ALL_FORMATS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = new Output({
|
||||||
|
format: new WavOutputFormat(),
|
||||||
|
target: new BufferTarget(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const conversion = await Conversion.init({
|
||||||
|
input,
|
||||||
|
output,
|
||||||
|
video: {
|
||||||
|
discard: true,
|
||||||
|
},
|
||||||
|
audio: {
|
||||||
|
forceTranscode: true,
|
||||||
|
},
|
||||||
|
trim: {
|
||||||
|
start: 0.4 / 48000,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await conversion.execute();
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user