@remotion/media 4.0.422 → 4.0.424
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.mjs
CHANGED
|
@@ -36,6 +36,9 @@ var __callDispose = (stack, error, hasError) => {
|
|
|
36
36
|
return next();
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
// src/index.ts
|
|
40
|
+
import { registerAc3Decoder } from "@mediabunny/ac3";
|
|
41
|
+
|
|
39
42
|
// src/audio/audio.tsx
|
|
40
43
|
import { Internals as Internals15, useRemotionEnvironment as useRemotionEnvironment2 } from "remotion";
|
|
41
44
|
|
|
@@ -1139,6 +1142,13 @@ class MediaPlayer {
|
|
|
1139
1142
|
}
|
|
1140
1143
|
this.setPlaybackTime(startTime, this.playbackRate * this.globalPlaybackRate);
|
|
1141
1144
|
if (audioTrack && this.sharedAudioContext) {
|
|
1145
|
+
const canDecode = await audioTrack.canDecode();
|
|
1146
|
+
if (!canDecode) {
|
|
1147
|
+
return { type: "cannot-decode" };
|
|
1148
|
+
}
|
|
1149
|
+
if (this.input.disposed) {
|
|
1150
|
+
return { type: "disposed" };
|
|
1151
|
+
}
|
|
1142
1152
|
this.audioIteratorManager = audioIteratorManager({
|
|
1143
1153
|
audioTrack,
|
|
1144
1154
|
delayPlaybackHandleIfNotPremounting: this.delayPlaybackHandleIfNotPremounting,
|
|
@@ -2402,6 +2412,17 @@ var makeKeyframeBank = async ({
|
|
|
2402
2412
|
let hasReachedEndOfVideo = false;
|
|
2403
2413
|
let lastUsed = Date.now();
|
|
2404
2414
|
let allocationSize = 0;
|
|
2415
|
+
const getDurationOfFrame = (timestamp) => {
|
|
2416
|
+
const index = frameTimestamps.indexOf(timestamp);
|
|
2417
|
+
if (index === -1) {
|
|
2418
|
+
throw new Error(`Frame ${timestamp} not found`);
|
|
2419
|
+
}
|
|
2420
|
+
const nextTimestamp = frameTimestamps[index + 1];
|
|
2421
|
+
if (!nextTimestamp) {
|
|
2422
|
+
return null;
|
|
2423
|
+
}
|
|
2424
|
+
return nextTimestamp - timestamp;
|
|
2425
|
+
};
|
|
2405
2426
|
const deleteFrameAtTimestamp = (timestamp) => {
|
|
2406
2427
|
allocationSize -= getAllocationSize(frames[timestamp]);
|
|
2407
2428
|
frameTimestamps.splice(frameTimestamps.indexOf(timestamp), 1);
|
|
@@ -2423,7 +2444,7 @@ var makeKeyframeBank = async ({
|
|
|
2423
2444
|
if (!frames[frameTimestamp]) {
|
|
2424
2445
|
continue;
|
|
2425
2446
|
}
|
|
2426
|
-
const
|
|
2447
|
+
const duration = getDurationOfFrame(frameTimestamp) ?? frames[frameTimestamp].duration;
|
|
2427
2448
|
if (frameTimestamp + duration < timestampInSeconds) {
|
|
2428
2449
|
deleteFrameAtTimestamp(frameTimestamp);
|
|
2429
2450
|
deletedTimestamps.push(frameTimestamp);
|
|
@@ -2442,7 +2463,8 @@ var makeKeyframeBank = async ({
|
|
|
2442
2463
|
if (!lastFrame) {
|
|
2443
2464
|
return true;
|
|
2444
2465
|
}
|
|
2445
|
-
|
|
2466
|
+
const duration = getDurationOfFrame(lastFrameTimestamp) ?? lastFrame.duration;
|
|
2467
|
+
return roundTo4Digits(lastFrameTimestamp + duration) > roundTo4Digits(timestamp);
|
|
2446
2468
|
};
|
|
2447
2469
|
const addFrame = (frame, logLevel) => {
|
|
2448
2470
|
if (frames[frame.timestamp]) {
|
|
@@ -2516,9 +2538,10 @@ var makeKeyframeBank = async ({
|
|
|
2516
2538
|
const firstTimestamp = frameTimestamps[0];
|
|
2517
2539
|
const lastTimestamp = frameTimestamps[frameTimestamps.length - 1];
|
|
2518
2540
|
const lastFrame = frames[lastTimestamp];
|
|
2541
|
+
const lastFrameDuration = getDurationOfFrame(lastTimestamp) ?? lastFrame.duration ?? 0;
|
|
2519
2542
|
return {
|
|
2520
2543
|
firstTimestamp,
|
|
2521
|
-
lastTimestamp: lastTimestamp +
|
|
2544
|
+
lastTimestamp: lastTimestamp + lastFrameDuration
|
|
2522
2545
|
};
|
|
2523
2546
|
};
|
|
2524
2547
|
const prepareForDeletion = (logLevel, reason) => {
|
|
@@ -3016,12 +3039,36 @@ var convertAudioData = ({
|
|
|
3016
3039
|
throw new Error("Cannot resample - the given sample rate would result in less than 1 sample");
|
|
3017
3040
|
}
|
|
3018
3041
|
const srcChannels = new Int16Array(srcNumberOfChannels * frameCount);
|
|
3019
|
-
audioData.
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3042
|
+
const isF32 = audioData.format === "f32" || audioData.format === "f32-planar";
|
|
3043
|
+
if (isF32) {
|
|
3044
|
+
const bytesPerPlane = frameCount * 4;
|
|
3045
|
+
const f32Buffer = new ArrayBuffer(srcNumberOfChannels * bytesPerPlane);
|
|
3046
|
+
for (let ch = 0;ch < srcNumberOfChannels; ch++) {
|
|
3047
|
+
audioData.copyTo(new Float32Array(f32Buffer, ch * bytesPerPlane, frameCount), { planeIndex: ch, frameOffset, frameCount, format: "f32-planar" });
|
|
3048
|
+
}
|
|
3049
|
+
const f32AudioData = new AudioData({
|
|
3050
|
+
format: "f32-planar",
|
|
3051
|
+
sampleRate: currentSampleRate,
|
|
3052
|
+
numberOfFrames: frameCount,
|
|
3053
|
+
numberOfChannels: srcNumberOfChannels,
|
|
3054
|
+
timestamp: audioData.timestamp,
|
|
3055
|
+
data: f32Buffer
|
|
3056
|
+
});
|
|
3057
|
+
f32AudioData.copyTo(srcChannels, {
|
|
3058
|
+
planeIndex: 0,
|
|
3059
|
+
format: FORMAT,
|
|
3060
|
+
frameOffset: 0,
|
|
3061
|
+
frameCount
|
|
3062
|
+
});
|
|
3063
|
+
f32AudioData.close();
|
|
3064
|
+
} else {
|
|
3065
|
+
audioData.copyTo(srcChannels, {
|
|
3066
|
+
planeIndex: 0,
|
|
3067
|
+
format: FORMAT,
|
|
3068
|
+
frameOffset,
|
|
3069
|
+
frameCount
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3025
3072
|
const data = new Int16Array(newNumberOfFrames * TARGET_NUMBER_OF_CHANNELS);
|
|
3026
3073
|
const chunkSize = frameCount / newNumberOfFrames;
|
|
3027
3074
|
const timestampOffsetMicroseconds = frameOffset / audioData.sampleRate * 1e6;
|
|
@@ -3670,7 +3717,7 @@ var addBroadcastChannelListener = () => {
|
|
|
3670
3717
|
};
|
|
3671
3718
|
window.remotion_broadcastChannel.postMessage(response);
|
|
3672
3719
|
}
|
|
3673
|
-
} else {
|
|
3720
|
+
} else if (data.type === "main-tab-ready") {} else {
|
|
3674
3721
|
throw new Error("Invalid message: " + JSON.stringify(data));
|
|
3675
3722
|
}
|
|
3676
3723
|
});
|
|
@@ -4913,9 +4960,11 @@ var Video = ({
|
|
|
4913
4960
|
});
|
|
4914
4961
|
};
|
|
4915
4962
|
Internals18.addSequenceStackTraces(Video);
|
|
4963
|
+
|
|
4916
4964
|
// src/index.ts
|
|
4917
4965
|
var experimental_Audio = Audio;
|
|
4918
4966
|
var experimental_Video = Video;
|
|
4967
|
+
registerAc3Decoder();
|
|
4919
4968
|
export {
|
|
4920
4969
|
experimental_Video,
|
|
4921
4970
|
experimental_Audio,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const getAllocationSize: (sample:
|
|
1
|
+
import type { VideoSampleWithoutDuration } from './keyframe-bank';
|
|
2
|
+
export declare const getAllocationSize: (sample: VideoSampleWithoutDuration) => number;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { VideoSample, VideoSampleSink } from 'mediabunny';
|
|
2
2
|
import { type LogLevel } from 'remotion';
|
|
3
|
+
export type VideoSampleWithoutDuration = Omit<VideoSample, 'duration'>;
|
|
3
4
|
export type KeyframeBank = {
|
|
4
5
|
src: string;
|
|
5
|
-
getFrameFromTimestamp: (timestamp: number, fps: number) => Promise<
|
|
6
|
+
getFrameFromTimestamp: (timestamp: number, fps: number) => Promise<VideoSampleWithoutDuration | null>;
|
|
6
7
|
prepareForDeletion: (logLevel: LogLevel, reason: string) => {
|
|
7
8
|
framesDeleted: number;
|
|
8
9
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/media",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.424",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/media"
|
|
9
9
|
},
|
|
10
|
-
"sideEffects": false,
|
|
11
10
|
"author": "Jonny Burger <jonny@remotion.dev>, Hunain Ahmed <junaidhunain6@gmail.com>",
|
|
12
11
|
"bugs": {
|
|
13
12
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
@@ -22,22 +21,23 @@
|
|
|
22
21
|
"make": "tsgo && bun --env-file=../.env.bundle bundle.ts"
|
|
23
22
|
},
|
|
24
23
|
"dependencies": {
|
|
25
|
-
"mediabunny": "1.
|
|
26
|
-
"
|
|
24
|
+
"mediabunny": "1.34.4",
|
|
25
|
+
"@mediabunny/ac3": "1.34.4",
|
|
26
|
+
"remotion": "4.0.424"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": ">=16.8.0",
|
|
30
30
|
"react-dom": ">=16.8.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
33
|
+
"@remotion/eslint-config-internal": "4.0.424",
|
|
34
34
|
"@vitest/browser-webdriverio": "4.0.9",
|
|
35
35
|
"eslint": "9.19.0",
|
|
36
36
|
"react": "19.2.3",
|
|
37
37
|
"react-dom": "19.2.3",
|
|
38
38
|
"vitest": "4.0.9",
|
|
39
39
|
"webdriverio": "9.19.2",
|
|
40
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
40
|
+
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [],
|
|
43
43
|
"publishConfig": {
|