@remotion/media 4.0.352 → 4.0.353
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/audio/props.d.ts +1 -2
- package/dist/audio-extraction/audio-iterator.d.ts +1 -1
- package/dist/audio-extraction/audio-iterator.js +2 -2
- package/dist/audio-extraction/audio-manager.d.ts +1 -1
- package/dist/audio-extraction/extract-audio.d.ts +1 -1
- package/dist/caches.d.ts +6 -6
- package/dist/caches.js +5 -6
- package/dist/convert-audiodata/resample-audiodata.js +3 -2
- package/dist/esm/index.mjs +45 -71
- package/dist/video-extraction/extract-frame-via-broadcast-channel.d.ts +1 -1
- package/dist/video-extraction/extract-frame.d.ts +1 -1
- package/dist/video-extraction/get-frames-since-keyframe.js +1 -1
- package/dist/video-extraction/keyframe-bank.d.ts +1 -1
- package/dist/video-extraction/keyframe-bank.js +7 -7
- package/dist/video-extraction/keyframe-manager.d.ts +1 -1
- package/dist/video-extraction/keyframe-manager.js +6 -6
- package/package.json +3 -3
- package/dist/audio-for-rendering.d.ts +0 -3
- package/dist/audio-for-rendering.js +0 -94
- package/dist/audio.d.ts +0 -3
- package/dist/audio.js +0 -60
- package/dist/audiodata-to-array.d.ts +0 -0
- package/dist/audiodata-to-array.js +0 -1
- package/dist/convert-audiodata/data-types.d.ts +0 -1
- package/dist/convert-audiodata/data-types.js +0 -22
- package/dist/convert-audiodata/is-planar-format.d.ts +0 -1
- package/dist/convert-audiodata/is-planar-format.js +0 -3
- package/dist/convert-audiodata/log-audiodata.d.ts +0 -1
- package/dist/convert-audiodata/log-audiodata.js +0 -8
- package/dist/convert-audiodata/trim-audiodata.d.ts +0 -0
- package/dist/convert-audiodata/trim-audiodata.js +0 -1
- package/dist/deserialized-audiodata.d.ts +0 -15
- package/dist/deserialized-audiodata.js +0 -26
- package/dist/extract-audio.d.ts +0 -7
- package/dist/extract-audio.js +0 -98
- package/dist/extract-frame-via-broadcast-channel.d.ts +0 -15
- package/dist/extract-frame-via-broadcast-channel.js +0 -104
- package/dist/extract-frame.d.ts +0 -27
- package/dist/extract-frame.js +0 -21
- package/dist/extrct-audio.d.ts +0 -7
- package/dist/extrct-audio.js +0 -94
- package/dist/get-frames-since-keyframe.d.ts +0 -22
- package/dist/get-frames-since-keyframe.js +0 -41
- package/dist/keyframe-bank.d.ts +0 -25
- package/dist/keyframe-bank.js +0 -120
- package/dist/keyframe-manager.d.ts +0 -23
- package/dist/keyframe-manager.js +0 -170
- package/dist/new-video-for-rendering.d.ts +0 -3
- package/dist/new-video-for-rendering.js +0 -108
- package/dist/new-video.d.ts +0 -3
- package/dist/new-video.js +0 -37
- package/dist/props.d.ts +0 -29
- package/dist/props.js +0 -1
- package/dist/remember-actual-matroska-timestamps.d.ts +0 -4
- package/dist/remember-actual-matroska-timestamps.js +0 -19
- package/dist/serialize-videoframe.d.ts +0 -0
- package/dist/serialize-videoframe.js +0 -1
- package/dist/video/media-player.d.ts +0 -64
- package/dist/video/media-player.js +0 -501
- package/dist/video/new-video-for-preview.d.ts +0 -10
- package/dist/video/new-video-for-preview.js +0 -114
- package/dist/video-extraction/media-player.d.ts +0 -64
- package/dist/video-extraction/media-player.js +0 -501
- package/dist/video-extraction/new-video-for-preview.d.ts +0 -10
- package/dist/video-extraction/new-video-for-preview.js +0 -114
- package/dist/video-for-rendering.d.ts +0 -3
- package/dist/video-for-rendering.js +0 -108
- package/dist/video.d.ts +0 -3
- package/dist/video.js +0 -37
package/dist/audio/props.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AudioSample, AudioSampleSink } from 'mediabunny';
|
|
2
|
-
import type
|
|
2
|
+
import { type LogLevel } from 'remotion';
|
|
3
3
|
import type { RememberActualMatroskaTimestamps } from '../video-extraction/remember-actual-matroska-timestamps';
|
|
4
4
|
export declare const makeAudioIterator: ({ audioSampleSink, isMatroska, startTimestamp, src, actualMatroskaTimestamps, }: {
|
|
5
5
|
audioSampleSink: AudioSampleSink;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Internals } from 'remotion';
|
|
1
2
|
import { SAFE_BACK_WINDOW_IN_SECONDS } from '../caches';
|
|
2
|
-
import { Log } from '../log';
|
|
3
3
|
import { makeAudioCache } from './audio-cache';
|
|
4
4
|
// https://discord.com/channels/@me/1409810025844838481/1415028953093111870
|
|
5
5
|
// Audio frames might have dependencies on previous and next frames so we need to decode a bit more
|
|
@@ -62,7 +62,7 @@ export const makeAudioIterator = ({ audioSampleSink, isMatroska, startTimestamp,
|
|
|
62
62
|
return samples;
|
|
63
63
|
};
|
|
64
64
|
const logOpenFrames = (logLevel) => {
|
|
65
|
-
Log.verbose(logLevel, '
|
|
65
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, 'Open audio samples for src', src, cache
|
|
66
66
|
.getOpenTimestamps()
|
|
67
67
|
.map((t) => t.toFixed(3))
|
|
68
68
|
.join(', '));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AudioSampleSink } from 'mediabunny';
|
|
2
|
-
import type { LogLevel } from '
|
|
2
|
+
import type { LogLevel } from 'remotion';
|
|
3
3
|
import type { RememberActualMatroskaTimestamps } from '../video-extraction/remember-actual-matroska-timestamps';
|
|
4
4
|
export declare const makeAudioManager: () => {
|
|
5
5
|
makeIterator: ({ timeInSeconds, src, audioSampleSink, isMatroska, actualMatroskaTimestamps, }: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type LogLevel } from 'remotion';
|
|
1
2
|
import type { PcmS16AudioData } from '../convert-audiodata/convert-audiodata';
|
|
2
|
-
import type { LogLevel } from '../log';
|
|
3
3
|
export declare const extractAudio: ({ src, timeInSeconds: unloopedTimeInSeconds, durationInSeconds, volume, logLevel, loop, }: {
|
|
4
4
|
src: string;
|
|
5
5
|
timeInSeconds: number;
|
package/dist/caches.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const keyframeManager: {
|
|
|
6
6
|
packetSink: import("mediabunny").EncodedPacketSink;
|
|
7
7
|
videoSampleSink: import("mediabunny").VideoSampleSink;
|
|
8
8
|
src: string;
|
|
9
|
-
logLevel:
|
|
9
|
+
logLevel: LogLevel;
|
|
10
10
|
}) => Promise<import("./video-extraction/keyframe-bank").KeyframeBank>;
|
|
11
11
|
addKeyframeBank: ({ src, bank, startTimestampInSeconds, }: {
|
|
12
12
|
src: string;
|
|
@@ -31,7 +31,7 @@ export declare const audioManager: {
|
|
|
31
31
|
getSamples: (ts: number, dur: number) => Promise<import("mediabunny").AudioSample[]>;
|
|
32
32
|
waitForCompletion: () => Promise<boolean>;
|
|
33
33
|
canSatisfyRequestedTime: (timestamp: number) => boolean;
|
|
34
|
-
logOpenFrames: (logLevel:
|
|
34
|
+
logOpenFrames: (logLevel: LogLevel) => void;
|
|
35
35
|
getCacheStats: () => {
|
|
36
36
|
count: number;
|
|
37
37
|
size: number;
|
|
@@ -46,13 +46,13 @@ export declare const audioManager: {
|
|
|
46
46
|
audioSampleSink: import("mediabunny").AudioSampleSink;
|
|
47
47
|
isMatroska: boolean;
|
|
48
48
|
actualMatroskaTimestamps: import("./video-extraction/remember-actual-matroska-timestamps").RememberActualMatroskaTimestamps;
|
|
49
|
-
logLevel:
|
|
49
|
+
logLevel: LogLevel;
|
|
50
50
|
}) => Promise<{
|
|
51
51
|
src: string;
|
|
52
52
|
getSamples: (ts: number, dur: number) => Promise<import("mediabunny").AudioSample[]>;
|
|
53
53
|
waitForCompletion: () => Promise<boolean>;
|
|
54
54
|
canSatisfyRequestedTime: (timestamp: number) => boolean;
|
|
55
|
-
logOpenFrames: (logLevel:
|
|
55
|
+
logOpenFrames: (logLevel: LogLevel) => void;
|
|
56
56
|
getCacheStats: () => {
|
|
57
57
|
count: number;
|
|
58
58
|
size: number;
|
|
@@ -70,7 +70,7 @@ export declare const audioManager: {
|
|
|
70
70
|
getSamples: (ts: number, dur: number) => Promise<import("mediabunny").AudioSample[]>;
|
|
71
71
|
waitForCompletion: () => Promise<boolean>;
|
|
72
72
|
canSatisfyRequestedTime: (timestamp: number) => boolean;
|
|
73
|
-
logOpenFrames: (logLevel:
|
|
73
|
+
logOpenFrames: (logLevel: LogLevel) => void;
|
|
74
74
|
getCacheStats: () => {
|
|
75
75
|
count: number;
|
|
76
76
|
size: number;
|
|
@@ -79,7 +79,7 @@ export declare const audioManager: {
|
|
|
79
79
|
prepareForDeletion: () => Promise<void>;
|
|
80
80
|
startTimestamp: number;
|
|
81
81
|
} | null;
|
|
82
|
-
logOpenFrames: (logLevel:
|
|
82
|
+
logOpenFrames: (logLevel: LogLevel) => void;
|
|
83
83
|
};
|
|
84
84
|
export declare const getTotalCacheStats: () => Promise<{
|
|
85
85
|
count: number;
|
package/dist/caches.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { cancelRender } from 'remotion';
|
|
1
|
+
import { cancelRender, Internals } from 'remotion';
|
|
2
2
|
import { makeAudioManager } from './audio-extraction/audio-manager';
|
|
3
|
-
import { Log } from './log';
|
|
4
3
|
import { makeKeyframeManager } from './video-extraction/keyframe-manager';
|
|
5
4
|
// TODO: make it dependent on the fps and concurrency
|
|
6
5
|
export const SAFE_BACK_WINDOW_IN_SECONDS = 1;
|
|
@@ -23,21 +22,21 @@ const getUncachedMaxCacheSize = (logLevel) => {
|
|
|
23
22
|
if (window.remotion_mediaCacheSizeInBytes > 20000 * 1024 * 1024) {
|
|
24
23
|
cancelRender(new Error(`The maximum value for the "mediaCacheSizeInBytes" prop is 20GB (${20000 * 1024 * 1024}), got: ${window.remotion_mediaCacheSizeInBytes}`));
|
|
25
24
|
}
|
|
26
|
-
Log.verbose(logLevel,
|
|
25
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Using cache size set using "mediaCacheSizeInBytes": ${(window.remotion_mediaCacheSizeInBytes / 1024 / 1024).toFixed(1)} MB`);
|
|
27
26
|
return window.remotion_mediaCacheSizeInBytes;
|
|
28
27
|
}
|
|
29
28
|
if (window.remotion_initialMemoryAvailable !== undefined &&
|
|
30
29
|
window.remotion_initialMemoryAvailable !== null) {
|
|
31
30
|
const value = window.remotion_initialMemoryAvailable / 2;
|
|
32
31
|
if (value < 240 * 1024 * 1024) {
|
|
33
|
-
Log.verbose(logLevel,
|
|
32
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Using cache size set based on minimum value of 240MB (which is more than half of the available system memory!)`);
|
|
34
33
|
return 240 * 1024 * 1024;
|
|
35
34
|
}
|
|
36
35
|
if (value > 20000 * 1024 * 1024) {
|
|
37
|
-
Log.verbose(logLevel,
|
|
36
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Using cache size set based on maximum value of 20GB (which is less than half of the available system memory)`);
|
|
38
37
|
return 20000 * 1024 * 1024;
|
|
39
38
|
}
|
|
40
|
-
Log.verbose(logLevel,
|
|
39
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Using cache size set based on available memory (50% of available memory): ${(value / 1024 / 1024).toFixed(1)} MB`);
|
|
41
40
|
return value;
|
|
42
41
|
}
|
|
43
42
|
return 1000 * 1000 * 1000; // 1GB
|
|
@@ -56,8 +56,9 @@ export const resampleAudioData = ({ srcNumberOfChannels, sourceChannels, destina
|
|
|
56
56
|
const c = getSourceValues(start, end, 2);
|
|
57
57
|
const sl = getSourceValues(start, end, 3);
|
|
58
58
|
const sr = getSourceValues(start, end, 4);
|
|
59
|
-
const
|
|
60
|
-
const
|
|
59
|
+
const sq = Math.sqrt(1 / 2);
|
|
60
|
+
const l2 = l + sq * (c + sl);
|
|
61
|
+
const r2 = r + sq * (c + sr);
|
|
61
62
|
destination[newFrameIndex * 2 + 0] = l2;
|
|
62
63
|
destination[newFrameIndex * 2 + 1] = r2;
|
|
63
64
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useCallback as useCallback2, useContext as useContext5 } from "react";
|
|
3
3
|
import {
|
|
4
4
|
cancelRender as cancelRender3,
|
|
5
|
-
Internals as
|
|
5
|
+
Internals as Internals6,
|
|
6
6
|
Sequence,
|
|
7
7
|
useRemotionEnvironment as useRemotionEnvironment3
|
|
8
8
|
} from "remotion";
|
|
@@ -45,48 +45,17 @@ var SharedAudioContext = createContext2(null);
|
|
|
45
45
|
import { useContext as useContext4, useLayoutEffect, useMemo as useMemo3, useState as useState3 } from "react";
|
|
46
46
|
import {
|
|
47
47
|
cancelRender as cancelRender2,
|
|
48
|
-
Internals,
|
|
48
|
+
Internals as Internals5,
|
|
49
49
|
useCurrentFrame,
|
|
50
50
|
useDelayRender,
|
|
51
51
|
useRemotionEnvironment as useRemotionEnvironment2
|
|
52
52
|
} from "remotion";
|
|
53
53
|
|
|
54
54
|
// src/caches.ts
|
|
55
|
-
import { cancelRender } from "remotion";
|
|
55
|
+
import { cancelRender, Internals as Internals4 } from "remotion";
|
|
56
56
|
|
|
57
|
-
// src/
|
|
58
|
-
|
|
59
|
-
var getNumberForLogLevel = (level) => {
|
|
60
|
-
return logLevels.indexOf(level);
|
|
61
|
-
};
|
|
62
|
-
var isEqualOrBelowLogLevel = (currentLevel, level) => {
|
|
63
|
-
return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
|
|
64
|
-
};
|
|
65
|
-
var Log2 = {
|
|
66
|
-
trace: (logLevel, ...args) => {
|
|
67
|
-
if (isEqualOrBelowLogLevel(logLevel, "trace")) {
|
|
68
|
-
return console.log(...args);
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
verbose: (logLevel, ...args) => {
|
|
72
|
-
if (isEqualOrBelowLogLevel(logLevel, "verbose")) {
|
|
73
|
-
return console.log(...args);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
info: (logLevel, ...args) => {
|
|
77
|
-
if (isEqualOrBelowLogLevel(logLevel, "info")) {
|
|
78
|
-
return console.log(...args);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
warn: (logLevel, ...args) => {
|
|
82
|
-
if (isEqualOrBelowLogLevel(logLevel, "warn")) {
|
|
83
|
-
return console.warn(...args);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
error: (...args) => {
|
|
87
|
-
return console.error(...args);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
57
|
+
// src/audio-extraction/audio-iterator.ts
|
|
58
|
+
import { Internals } from "remotion";
|
|
90
59
|
|
|
91
60
|
// src/audio-extraction/audio-cache.ts
|
|
92
61
|
var makeAudioCache = () => {
|
|
@@ -206,7 +175,7 @@ var makeAudioIterator = ({
|
|
|
206
175
|
return samples;
|
|
207
176
|
};
|
|
208
177
|
const logOpenFrames = (logLevel) => {
|
|
209
|
-
|
|
178
|
+
Internals.Log.verbose({ logLevel, tag: "@remotion/media" }, "Open audio samples for src", src, cache.getOpenTimestamps().map((t) => t.toFixed(3)).join(", "));
|
|
210
179
|
};
|
|
211
180
|
const getCacheStats = () => {
|
|
212
181
|
return {
|
|
@@ -343,6 +312,9 @@ var makeAudioManager = () => {
|
|
|
343
312
|
};
|
|
344
313
|
};
|
|
345
314
|
|
|
315
|
+
// src/video-extraction/keyframe-manager.ts
|
|
316
|
+
import { Internals as Internals3 } from "remotion";
|
|
317
|
+
|
|
346
318
|
// ../../node_modules/.pnpm/mediabunny@1.17.0/node_modules/mediabunny/dist/modules/src/misc.js
|
|
347
319
|
/*!
|
|
348
320
|
* Copyright (c) 2025-present, Vanilagy and contributors
|
|
@@ -13280,6 +13252,7 @@ class Input {
|
|
|
13280
13252
|
*/
|
|
13281
13253
|
|
|
13282
13254
|
// src/video-extraction/keyframe-bank.ts
|
|
13255
|
+
import { Internals as Internals2 } from "remotion";
|
|
13283
13256
|
var roundTo4Digits = (timestamp) => {
|
|
13284
13257
|
return Math.round(timestamp * 1000) / 1000;
|
|
13285
13258
|
};
|
|
@@ -13291,7 +13264,7 @@ var makeKeyframeBank = ({
|
|
|
13291
13264
|
const frames = {};
|
|
13292
13265
|
const frameTimestamps = [];
|
|
13293
13266
|
let lastUsed = Date.now();
|
|
13294
|
-
let
|
|
13267
|
+
let allocationSize = 0;
|
|
13295
13268
|
const hasDecodedEnoughForTimestamp = (timestamp) => {
|
|
13296
13269
|
const lastFrameTimestamp = frameTimestamps[frameTimestamps.length - 1];
|
|
13297
13270
|
if (!lastFrameTimestamp) {
|
|
@@ -13306,7 +13279,7 @@ var makeKeyframeBank = ({
|
|
|
13306
13279
|
const addFrame = (frame) => {
|
|
13307
13280
|
frames[frame.timestamp] = frame;
|
|
13308
13281
|
frameTimestamps.push(frame.timestamp);
|
|
13309
|
-
|
|
13282
|
+
allocationSize += frame.allocationSize();
|
|
13310
13283
|
lastUsed = Date.now();
|
|
13311
13284
|
};
|
|
13312
13285
|
const ensureEnoughFramesForTimestamp = async (timestamp) => {
|
|
@@ -13353,7 +13326,7 @@ var makeKeyframeBank = ({
|
|
|
13353
13326
|
if (!frames[frameTimestamp]) {
|
|
13354
13327
|
continue;
|
|
13355
13328
|
}
|
|
13356
|
-
|
|
13329
|
+
allocationSize -= frames[frameTimestamp].allocationSize();
|
|
13357
13330
|
frames[frameTimestamp].close();
|
|
13358
13331
|
delete frames[frameTimestamp];
|
|
13359
13332
|
}
|
|
@@ -13373,17 +13346,17 @@ var makeKeyframeBank = ({
|
|
|
13373
13346
|
if (!frames[frameTimestamp]) {
|
|
13374
13347
|
continue;
|
|
13375
13348
|
}
|
|
13376
|
-
|
|
13349
|
+
allocationSize -= frames[frameTimestamp].allocationSize();
|
|
13377
13350
|
frameTimestamps.splice(frameTimestamps.indexOf(frameTimestamp), 1);
|
|
13378
13351
|
frames[frameTimestamp].close();
|
|
13379
13352
|
delete frames[frameTimestamp];
|
|
13380
|
-
|
|
13353
|
+
Internals2.Log.verbose({ logLevel, tag: "@remotion/media" }, `Deleted frame ${frameTimestamp} for src ${src}`);
|
|
13381
13354
|
}
|
|
13382
13355
|
}
|
|
13383
13356
|
};
|
|
13384
13357
|
const getOpenFrameCount = () => {
|
|
13385
13358
|
return {
|
|
13386
|
-
size:
|
|
13359
|
+
size: allocationSize,
|
|
13387
13360
|
timestamps: frameTimestamps
|
|
13388
13361
|
};
|
|
13389
13362
|
};
|
|
@@ -13457,7 +13430,7 @@ var getFramesSinceKeyframe = async ({
|
|
|
13457
13430
|
startPacket
|
|
13458
13431
|
}) => {
|
|
13459
13432
|
const nextKeyPacket = await packetSink.getNextKeyPacket(startPacket, {
|
|
13460
|
-
verifyKeyPackets:
|
|
13433
|
+
verifyKeyPackets: true
|
|
13461
13434
|
});
|
|
13462
13435
|
const sampleIterator = videoSampleSink.samples(startPacket.timestamp, nextKeyPacket ? nextKeyPacket.timestamp : Infinity);
|
|
13463
13436
|
const keyframeBank = makeKeyframeBank({
|
|
@@ -13491,10 +13464,10 @@ var makeKeyframeManager = () => {
|
|
|
13491
13464
|
if (size === 0) {
|
|
13492
13465
|
continue;
|
|
13493
13466
|
}
|
|
13494
|
-
|
|
13467
|
+
Internals3.Log.verbose({ logLevel, tag: "@remotion/media" }, `Open frames for src ${src}: ${timestamps.join(", ")}`);
|
|
13495
13468
|
}
|
|
13496
13469
|
}
|
|
13497
|
-
|
|
13470
|
+
Internals3.Log.verbose({ logLevel, tag: "@remotion/media" }, `Video cache stats: ${count} open frames, ${totalSize} bytes`);
|
|
13498
13471
|
};
|
|
13499
13472
|
const getCacheStats = async () => {
|
|
13500
13473
|
let count = 0;
|
|
@@ -13535,7 +13508,7 @@ var makeKeyframeManager = () => {
|
|
|
13535
13508
|
if (mostInThePastBank) {
|
|
13536
13509
|
await mostInThePastBank.prepareForDeletion();
|
|
13537
13510
|
delete sources[mostInThePastSrc][mostInThePastBank.startTimestampInSeconds];
|
|
13538
|
-
|
|
13511
|
+
Internals3.Log.verbose({ logLevel, tag: "@remotion/media" }, `Deleted frames for src ${mostInThePastSrc} from ${mostInThePastBank.startTimestampInSeconds}sec to ${mostInThePastBank.endTimestampInSeconds}sec to free up memory.`);
|
|
13539
13512
|
}
|
|
13540
13513
|
};
|
|
13541
13514
|
const ensureToStayUnderMaxCacheSize = async (logLevel) => {
|
|
@@ -13561,7 +13534,7 @@ var makeKeyframeManager = () => {
|
|
|
13561
13534
|
const { endTimestampInSeconds, startTimestampInSeconds } = bank;
|
|
13562
13535
|
if (endTimestampInSeconds < threshold) {
|
|
13563
13536
|
await bank.prepareForDeletion();
|
|
13564
|
-
|
|
13537
|
+
Internals3.Log.verbose({ logLevel, tag: "@remotion/media" }, `[Video] Cleared frames for src ${src} from ${startTimestampInSeconds}sec to ${endTimestampInSeconds}sec`);
|
|
13565
13538
|
delete sources[src][startTimeInSeconds];
|
|
13566
13539
|
} else {
|
|
13567
13540
|
bank.deleteFramesBeforeTimestamp({
|
|
@@ -13600,7 +13573,7 @@ var makeKeyframeManager = () => {
|
|
|
13600
13573
|
if (await (await existingBank).hasTimestampInSecond(timestamp)) {
|
|
13601
13574
|
return existingBank;
|
|
13602
13575
|
}
|
|
13603
|
-
|
|
13576
|
+
Internals3.Log.verbose({ logLevel, tag: "@remotion/media" }, `Keyframe bank exists but frames have already been evicted!`);
|
|
13604
13577
|
await (await existingBank).prepareForDeletion();
|
|
13605
13578
|
delete sources[src][startTimestampInSeconds];
|
|
13606
13579
|
const replacementKeybank = getFramesSinceKeyframe({
|
|
@@ -13672,20 +13645,20 @@ var getUncachedMaxCacheSize = (logLevel) => {
|
|
|
13672
13645
|
if (window.remotion_mediaCacheSizeInBytes > 20000 * 1024 * 1024) {
|
|
13673
13646
|
cancelRender(new Error(`The maximum value for the "mediaCacheSizeInBytes" prop is 20GB (${20000 * 1024 * 1024}), got: ${window.remotion_mediaCacheSizeInBytes}`));
|
|
13674
13647
|
}
|
|
13675
|
-
|
|
13648
|
+
Internals4.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set using "mediaCacheSizeInBytes": ${(window.remotion_mediaCacheSizeInBytes / 1024 / 1024).toFixed(1)} MB`);
|
|
13676
13649
|
return window.remotion_mediaCacheSizeInBytes;
|
|
13677
13650
|
}
|
|
13678
13651
|
if (window.remotion_initialMemoryAvailable !== undefined && window.remotion_initialMemoryAvailable !== null) {
|
|
13679
13652
|
const value = window.remotion_initialMemoryAvailable / 2;
|
|
13680
13653
|
if (value < 240 * 1024 * 1024) {
|
|
13681
|
-
|
|
13654
|
+
Internals4.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on minimum value of 240MB (which is more than half of the available system memory!)`);
|
|
13682
13655
|
return 240 * 1024 * 1024;
|
|
13683
13656
|
}
|
|
13684
13657
|
if (value > 20000 * 1024 * 1024) {
|
|
13685
|
-
|
|
13658
|
+
Internals4.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on maximum value of 20GB (which is less than half of the available system memory)`);
|
|
13686
13659
|
return 20000 * 1024 * 1024;
|
|
13687
13660
|
}
|
|
13688
|
-
|
|
13661
|
+
Internals4.Log.verbose({ logLevel, tag: "@remotion/media" }, `Using cache size set based on available memory (50% of available memory): ${(value / 1024 / 1024).toFixed(1)} MB`);
|
|
13689
13662
|
return value;
|
|
13690
13663
|
}
|
|
13691
13664
|
return 1000 * 1000 * 1000;
|
|
@@ -13796,8 +13769,9 @@ var resampleAudioData = ({
|
|
|
13796
13769
|
const c = getSourceValues(start, end, 2);
|
|
13797
13770
|
const sl = getSourceValues(start, end, 3);
|
|
13798
13771
|
const sr = getSourceValues(start, end, 4);
|
|
13799
|
-
const
|
|
13800
|
-
const
|
|
13772
|
+
const sq = Math.sqrt(1 / 2);
|
|
13773
|
+
const l2 = l + sq * (c + sl);
|
|
13774
|
+
const r2 = r + sq * (c + sr);
|
|
13801
13775
|
destination[newFrameIndex * 2 + 0] = l2;
|
|
13802
13776
|
destination[newFrameIndex * 2 + 1] = r2;
|
|
13803
13777
|
} else {
|
|
@@ -14119,11 +14093,11 @@ var AudioForRendering = ({
|
|
|
14119
14093
|
logLevel = window.remotion_logLevel,
|
|
14120
14094
|
loop
|
|
14121
14095
|
}) => {
|
|
14122
|
-
const absoluteFrame =
|
|
14123
|
-
const videoConfig =
|
|
14124
|
-
const { registerRenderAsset, unregisterRenderAsset } = useContext4(
|
|
14096
|
+
const absoluteFrame = Internals5.useTimelinePosition();
|
|
14097
|
+
const videoConfig = Internals5.useUnsafeVideoConfig();
|
|
14098
|
+
const { registerRenderAsset, unregisterRenderAsset } = useContext4(Internals5.RenderAssetManager);
|
|
14125
14099
|
const frame = useCurrentFrame();
|
|
14126
|
-
const volumePropsFrame =
|
|
14100
|
+
const volumePropsFrame = Internals5.useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
|
|
14127
14101
|
const environment = useRemotionEnvironment2();
|
|
14128
14102
|
const [id] = useState3(() => `${Math.random()}`.replace("0.", ""));
|
|
14129
14103
|
if (!videoConfig) {
|
|
@@ -14132,12 +14106,12 @@ var AudioForRendering = ({
|
|
|
14132
14106
|
if (!src) {
|
|
14133
14107
|
throw new TypeError("No `src` was passed to <Audio>.");
|
|
14134
14108
|
}
|
|
14135
|
-
const volume =
|
|
14109
|
+
const volume = Internals5.evaluateVolume({
|
|
14136
14110
|
volume: volumeProp,
|
|
14137
14111
|
frame: volumePropsFrame,
|
|
14138
14112
|
mediaVolume: 1
|
|
14139
14113
|
});
|
|
14140
|
-
|
|
14114
|
+
Internals5.warnAboutTooHighVolume(volume);
|
|
14141
14115
|
const shouldRenderAudio = useMemo3(() => {
|
|
14142
14116
|
if (!window.remotion_audioEnabled) {
|
|
14143
14117
|
return false;
|
|
@@ -14220,7 +14194,7 @@ var {
|
|
|
14220
14194
|
resolveTrimProps,
|
|
14221
14195
|
validateMediaProps,
|
|
14222
14196
|
AudioForPreview
|
|
14223
|
-
} =
|
|
14197
|
+
} = Internals6;
|
|
14224
14198
|
var Audio = (props) => {
|
|
14225
14199
|
const audioContext = useContext5(SharedAudioContext);
|
|
14226
14200
|
const {
|
|
@@ -14307,7 +14281,7 @@ var Audio = (props) => {
|
|
|
14307
14281
|
};
|
|
14308
14282
|
// src/video/video.tsx
|
|
14309
14283
|
import { useCallback as useCallback3 } from "react";
|
|
14310
|
-
import { Internals as
|
|
14284
|
+
import { Internals as Internals8, Sequence as Sequence2, useRemotionEnvironment as useRemotionEnvironment5 } from "remotion";
|
|
14311
14285
|
|
|
14312
14286
|
// src/video/video-for-rendering.tsx
|
|
14313
14287
|
import {
|
|
@@ -14319,7 +14293,7 @@ import {
|
|
|
14319
14293
|
} from "react";
|
|
14320
14294
|
import {
|
|
14321
14295
|
cancelRender as cancelRender4,
|
|
14322
|
-
Internals as
|
|
14296
|
+
Internals as Internals7,
|
|
14323
14297
|
useCurrentFrame as useCurrentFrame2,
|
|
14324
14298
|
useDelayRender as useDelayRender2,
|
|
14325
14299
|
useRemotionEnvironment as useRemotionEnvironment4,
|
|
@@ -14340,23 +14314,23 @@ var VideoForRendering = ({
|
|
|
14340
14314
|
style,
|
|
14341
14315
|
className
|
|
14342
14316
|
}) => {
|
|
14343
|
-
const absoluteFrame =
|
|
14317
|
+
const absoluteFrame = Internals7.useTimelinePosition();
|
|
14344
14318
|
const { fps } = useVideoConfig();
|
|
14345
14319
|
const canvasRef = useRef2(null);
|
|
14346
|
-
const { registerRenderAsset, unregisterRenderAsset } = useContext6(
|
|
14320
|
+
const { registerRenderAsset, unregisterRenderAsset } = useContext6(Internals7.RenderAssetManager);
|
|
14347
14321
|
const frame = useCurrentFrame2();
|
|
14348
|
-
const volumePropsFrame =
|
|
14322
|
+
const volumePropsFrame = Internals7.useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
|
|
14349
14323
|
const environment = useRemotionEnvironment4();
|
|
14350
14324
|
const [id] = useState4(() => `${Math.random()}`.replace("0.", ""));
|
|
14351
14325
|
if (!src) {
|
|
14352
14326
|
throw new TypeError("No `src` was passed to <Video>.");
|
|
14353
14327
|
}
|
|
14354
|
-
const volume =
|
|
14328
|
+
const volume = Internals7.evaluateVolume({
|
|
14355
14329
|
volume: volumeProp,
|
|
14356
14330
|
frame: volumePropsFrame,
|
|
14357
14331
|
mediaVolume: 1
|
|
14358
14332
|
});
|
|
14359
|
-
|
|
14333
|
+
Internals7.warnAboutTooHighVolume(volume);
|
|
14360
14334
|
const shouldRenderAudio = useMemo4(() => {
|
|
14361
14335
|
if (!window.remotion_audioEnabled) {
|
|
14362
14336
|
return false;
|
|
@@ -14447,7 +14421,7 @@ var VideoForRendering = ({
|
|
|
14447
14421
|
loop
|
|
14448
14422
|
]);
|
|
14449
14423
|
const classNameValue = useMemo4(() => {
|
|
14450
|
-
return [
|
|
14424
|
+
return [Internals7.OBJECTFIT_CONTAIN_CLASS_NAME, className].filter(Internals7.truthy).join(" ");
|
|
14451
14425
|
}, [className]);
|
|
14452
14426
|
return /* @__PURE__ */ jsx3("canvas", {
|
|
14453
14427
|
ref: canvasRef,
|
|
@@ -14463,7 +14437,7 @@ var {
|
|
|
14463
14437
|
resolveTrimProps: resolveTrimProps2,
|
|
14464
14438
|
validateMediaProps: validateMediaProps2,
|
|
14465
14439
|
VideoForPreview
|
|
14466
|
-
} =
|
|
14440
|
+
} = Internals8;
|
|
14467
14441
|
var Video = (props) => {
|
|
14468
14442
|
const {
|
|
14469
14443
|
trimBefore,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type LogLevel } from 'remotion';
|
|
1
2
|
import type { PcmS16AudioData } from '../convert-audiodata/convert-audiodata';
|
|
2
|
-
import type { LogLevel } from '../log';
|
|
3
3
|
export declare const extractFrameViaBroadcastChannel: ({ src, timeInSeconds, logLevel, durationInSeconds, includeAudio, includeVideo, isClientSideRendering, volume, loop, }: {
|
|
4
4
|
src: string;
|
|
5
5
|
timeInSeconds: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LogLevel } from 'remotion';
|
|
2
2
|
import { type GetSink } from './get-frames-since-keyframe';
|
|
3
3
|
export declare const sinkPromises: Record<string, Promise<GetSink>>;
|
|
4
4
|
export declare const extractFrame: ({ src, timeInSeconds: unloopedTimeinSeconds, logLevel, loop, }: {
|
|
@@ -30,7 +30,7 @@ export const getSinks = async (src) => {
|
|
|
30
30
|
};
|
|
31
31
|
export const getFramesSinceKeyframe = async ({ packetSink, videoSampleSink, startPacket, }) => {
|
|
32
32
|
const nextKeyPacket = await packetSink.getNextKeyPacket(startPacket, {
|
|
33
|
-
verifyKeyPackets:
|
|
33
|
+
verifyKeyPackets: true,
|
|
34
34
|
});
|
|
35
35
|
const sampleIterator = videoSampleSink.samples(startPacket.timestamp, nextKeyPacket ? nextKeyPacket.timestamp : Infinity);
|
|
36
36
|
const keyframeBank = makeKeyframeBank({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Internals } from 'remotion';
|
|
2
2
|
// Round to only 4 digits, because WebM has a timescale of 1_000, e.g. framer.webm
|
|
3
3
|
const roundTo4Digits = (timestamp) => {
|
|
4
4
|
return Math.round(timestamp * 1000) / 1000;
|
|
@@ -7,7 +7,7 @@ export const makeKeyframeBank = ({ startTimestampInSeconds, endTimestampInSecond
|
|
|
7
7
|
const frames = {};
|
|
8
8
|
const frameTimestamps = [];
|
|
9
9
|
let lastUsed = Date.now();
|
|
10
|
-
let
|
|
10
|
+
let allocationSize = 0;
|
|
11
11
|
const hasDecodedEnoughForTimestamp = (timestamp) => {
|
|
12
12
|
const lastFrameTimestamp = frameTimestamps[frameTimestamps.length - 1];
|
|
13
13
|
if (!lastFrameTimestamp) {
|
|
@@ -24,7 +24,7 @@ export const makeKeyframeBank = ({ startTimestampInSeconds, endTimestampInSecond
|
|
|
24
24
|
const addFrame = (frame) => {
|
|
25
25
|
frames[frame.timestamp] = frame;
|
|
26
26
|
frameTimestamps.push(frame.timestamp);
|
|
27
|
-
|
|
27
|
+
allocationSize += frame.allocationSize();
|
|
28
28
|
lastUsed = Date.now();
|
|
29
29
|
};
|
|
30
30
|
const ensureEnoughFramesForTimestamp = async (timestamp) => {
|
|
@@ -72,7 +72,7 @@ export const makeKeyframeBank = ({ startTimestampInSeconds, endTimestampInSecond
|
|
|
72
72
|
if (!frames[frameTimestamp]) {
|
|
73
73
|
continue;
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
allocationSize -= frames[frameTimestamp].allocationSize();
|
|
76
76
|
frames[frameTimestamp].close();
|
|
77
77
|
delete frames[frameTimestamp];
|
|
78
78
|
}
|
|
@@ -89,17 +89,17 @@ export const makeKeyframeBank = ({ startTimestampInSeconds, endTimestampInSecond
|
|
|
89
89
|
if (!frames[frameTimestamp]) {
|
|
90
90
|
continue;
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
allocationSize -= frames[frameTimestamp].allocationSize();
|
|
93
93
|
frameTimestamps.splice(frameTimestamps.indexOf(frameTimestamp), 1);
|
|
94
94
|
frames[frameTimestamp].close();
|
|
95
95
|
delete frames[frameTimestamp];
|
|
96
|
-
Log.verbose(logLevel, `
|
|
96
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Deleted frame ${frameTimestamp} for src ${src}`);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
const getOpenFrameCount = () => {
|
|
101
101
|
return {
|
|
102
|
-
size:
|
|
102
|
+
size: allocationSize,
|
|
103
103
|
timestamps: frameTimestamps,
|
|
104
104
|
};
|
|
105
105
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EncodedPacketSink, VideoSampleSink } from 'mediabunny';
|
|
2
|
-
import type
|
|
2
|
+
import { type LogLevel } from 'remotion';
|
|
3
3
|
import { type KeyframeBank } from './keyframe-bank';
|
|
4
4
|
export declare const makeKeyframeManager: () => {
|
|
5
5
|
requestKeyframeBank: ({ packetSink, timestamp, videoSampleSink, src, logLevel, }: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Internals } from 'remotion';
|
|
1
2
|
import { getMaxVideoCacheSize, getTotalCacheStats, SAFE_BACK_WINDOW_IN_SECONDS, } from '../caches';
|
|
2
|
-
import { Log } from '../log';
|
|
3
3
|
import { getFramesSinceKeyframe } from './get-frames-since-keyframe';
|
|
4
4
|
export const makeKeyframeManager = () => {
|
|
5
5
|
// src => {[startTimestampInSeconds]: KeyframeBank
|
|
@@ -20,10 +20,10 @@ export const makeKeyframeManager = () => {
|
|
|
20
20
|
if (size === 0) {
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
|
-
Log.verbose(logLevel, `
|
|
23
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Open frames for src ${src}: ${timestamps.join(', ')}`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
Log.verbose(logLevel, `
|
|
26
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Video cache stats: ${count} open frames, ${totalSize} bytes`);
|
|
27
27
|
};
|
|
28
28
|
const getCacheStats = async () => {
|
|
29
29
|
let count = 0;
|
|
@@ -64,7 +64,7 @@ export const makeKeyframeManager = () => {
|
|
|
64
64
|
if (mostInThePastBank) {
|
|
65
65
|
await mostInThePastBank.prepareForDeletion();
|
|
66
66
|
delete sources[mostInThePastSrc][mostInThePastBank.startTimestampInSeconds];
|
|
67
|
-
Log.verbose(logLevel, `
|
|
67
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Deleted frames for src ${mostInThePastSrc} from ${mostInThePastBank.startTimestampInSeconds}sec to ${mostInThePastBank.endTimestampInSeconds}sec to free up memory.`);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
const ensureToStayUnderMaxCacheSize = async (logLevel) => {
|
|
@@ -86,7 +86,7 @@ export const makeKeyframeManager = () => {
|
|
|
86
86
|
const { endTimestampInSeconds, startTimestampInSeconds } = bank;
|
|
87
87
|
if (endTimestampInSeconds < threshold) {
|
|
88
88
|
await bank.prepareForDeletion();
|
|
89
|
-
Log.verbose(logLevel, `[Video] Cleared frames for src ${src} from ${startTimestampInSeconds}sec to ${endTimestampInSeconds}sec`);
|
|
89
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `[Video] Cleared frames for src ${src} from ${startTimestampInSeconds}sec to ${endTimestampInSeconds}sec`);
|
|
90
90
|
delete sources[src][startTimeInSeconds];
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
@@ -122,7 +122,7 @@ export const makeKeyframeManager = () => {
|
|
|
122
122
|
if (await (await existingBank).hasTimestampInSecond(timestamp)) {
|
|
123
123
|
return existingBank;
|
|
124
124
|
}
|
|
125
|
-
Log.verbose(logLevel, `
|
|
125
|
+
Internals.Log.verbose({ logLevel, tag: '@remotion/media' }, `Keyframe bank exists but frames have already been evicted!`);
|
|
126
126
|
// Bank exists but frames have already been evicted!
|
|
127
127
|
// First delete it entirely
|
|
128
128
|
await (await existingBank).prepareForDeletion();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/media",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.353",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"mediabunny": "1.17.0",
|
|
17
17
|
"webdriverio": "9.19.2",
|
|
18
|
-
"remotion": "4.0.
|
|
18
|
+
"remotion": "4.0.353"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": ">=16.8.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"react": "19.0.0",
|
|
28
28
|
"react-dom": "19.0.0",
|
|
29
29
|
"vitest": "3.2.4",
|
|
30
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
30
|
+
"@remotion/eslint-config-internal": "4.0.353"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [],
|
|
33
33
|
"publishConfig": {
|