@remotion/renderer 4.0.489 → 4.0.490
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/assets/calculate-asset-positions.js +57 -31
- package/dist/esm/index.mjs +49 -27
- package/package.json +13 -13
|
@@ -5,39 +5,68 @@ const filter_asset_types_1 = require("../filter-asset-types");
|
|
|
5
5
|
const resolve_asset_src_1 = require("../resolve-asset-src");
|
|
6
6
|
const flatten_volume_array_1 = require("./flatten-volume-array");
|
|
7
7
|
const types_1 = require("./types");
|
|
8
|
-
const
|
|
9
|
-
return a.id === b.id;
|
|
10
|
-
};
|
|
11
|
-
const findFrom = (target, renderAsset) => {
|
|
12
|
-
const index = target.findIndex((a) => areEqual(a, renderAsset));
|
|
13
|
-
if (index === -1) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
target.splice(index, 1);
|
|
17
|
-
return true;
|
|
18
|
-
};
|
|
19
|
-
const copyAndDeduplicateAssets = (renderAssets) => {
|
|
8
|
+
const deduplicateAssets = (renderAssets) => {
|
|
20
9
|
const onlyAudioAndVideo = (0, filter_asset_types_1.onlyAudioAndVideoAssets)(renderAssets);
|
|
10
|
+
const seenIds = new Set();
|
|
21
11
|
const deduplicated = [];
|
|
22
12
|
for (const renderAsset of onlyAudioAndVideo) {
|
|
23
|
-
if (!
|
|
13
|
+
if (!seenIds.has(renderAsset.id)) {
|
|
14
|
+
seenIds.add(renderAsset.id);
|
|
24
15
|
deduplicated.push(renderAsset);
|
|
25
16
|
}
|
|
26
17
|
}
|
|
27
18
|
return deduplicated;
|
|
28
19
|
};
|
|
20
|
+
const indexUncompressedAssets = (renderAssets) => {
|
|
21
|
+
const referencedAssets = new Set();
|
|
22
|
+
for (const renderAsset of renderAssets) {
|
|
23
|
+
if (renderAsset.src.startsWith('same-as')) {
|
|
24
|
+
referencedAssets.add(renderAsset.src);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const assetsByReference = new Map();
|
|
28
|
+
for (const renderAsset of renderAssets) {
|
|
29
|
+
if (referencedAssets.size === 0) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
if (renderAsset.src.startsWith('same-as')) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const reference = `same-as-${renderAsset.id}-${renderAsset.frame}`;
|
|
36
|
+
if (referencedAssets.has(reference)) {
|
|
37
|
+
assetsByReference.set(reference, renderAsset);
|
|
38
|
+
referencedAssets.delete(reference);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return assetsByReference;
|
|
42
|
+
};
|
|
29
43
|
const calculateAssetPositions = (frames) => {
|
|
30
|
-
var _a, _b;
|
|
31
44
|
const assets = [];
|
|
45
|
+
// Assets that have started but not yet ended, keyed by asset id.
|
|
46
|
+
// Since assets are deduplicated by id within a frame, at most one
|
|
47
|
+
// asset per id is open at a time.
|
|
48
|
+
const openAssets = new Map();
|
|
32
49
|
const flattened = frames.flat(1);
|
|
50
|
+
const uncompressedAssets = indexUncompressedAssets(flattened);
|
|
33
51
|
for (let frame = 0; frame < frames.length; frame++) {
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
52
|
+
const current = deduplicateAssets(frames[frame]);
|
|
53
|
+
const currentIds = new Set(current.map((a) => a.id));
|
|
54
|
+
for (const [id, openAsset] of openAssets) {
|
|
55
|
+
if (!currentIds.has(id)) {
|
|
56
|
+
// The asset was last present on the previous frame.
|
|
57
|
+
// Duration calculation:
|
|
58
|
+
// start 0, present for frames 0-59, gone at frame 60:
|
|
59
|
+
// 60 - 0 ==> 60 frames duration
|
|
60
|
+
openAsset.duration = frame - openAsset.startInVideo;
|
|
61
|
+
openAssets.delete(id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
37
64
|
for (const asset of current) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
65
|
+
let openAsset = openAssets.get(asset.id);
|
|
66
|
+
if (openAsset === undefined) {
|
|
67
|
+
const uncompressedAsset = uncompressedAssets.get(asset.src);
|
|
68
|
+
openAsset = {
|
|
69
|
+
src: (0, resolve_asset_src_1.resolveAssetSrc)((0, types_1.uncompressMediaAsset)(uncompressedAsset ? [uncompressedAsset] : flattened, asset).src),
|
|
41
70
|
type: asset.type,
|
|
42
71
|
duration: null,
|
|
43
72
|
id: asset.id,
|
|
@@ -48,20 +77,17 @@ const calculateAssetPositions = (frames) => {
|
|
|
48
77
|
toneFrequency: asset.toneFrequency,
|
|
49
78
|
audioStartFrame: asset.audioStartFrame,
|
|
50
79
|
audioStreamIndex: asset.audioStreamIndex,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!found)
|
|
55
|
-
throw new Error('something wrong');
|
|
56
|
-
if (!findFrom(next, asset)) {
|
|
57
|
-
// Duration calculation:
|
|
58
|
-
// start 0, range 0-59:
|
|
59
|
-
// 59 - 0 + 1 ==> 60 frames duration
|
|
60
|
-
found.duration = frame - found.startInVideo + 1;
|
|
80
|
+
};
|
|
81
|
+
assets.push(openAsset);
|
|
82
|
+
openAssets.set(asset.id, openAsset);
|
|
61
83
|
}
|
|
62
|
-
|
|
84
|
+
openAsset.volume.push(asset.volume);
|
|
63
85
|
}
|
|
64
86
|
}
|
|
87
|
+
// Assets that lasted until the end of the video.
|
|
88
|
+
for (const openAsset of openAssets.values()) {
|
|
89
|
+
openAsset.duration = frames.length - openAsset.startInVideo;
|
|
90
|
+
}
|
|
65
91
|
for (const asset of assets) {
|
|
66
92
|
if (asset.duration === null) {
|
|
67
93
|
throw new Error('duration is unexpectedly null');
|
package/dist/esm/index.mjs
CHANGED
|
@@ -22102,38 +22102,61 @@ var uncompressMediaAsset = (allRenderAssets, assetToUncompress) => {
|
|
|
22102
22102
|
};
|
|
22103
22103
|
|
|
22104
22104
|
// src/assets/calculate-asset-positions.ts
|
|
22105
|
-
var
|
|
22106
|
-
return a.id === b.id;
|
|
22107
|
-
};
|
|
22108
|
-
var findFrom = (target, renderAsset) => {
|
|
22109
|
-
const index = target.findIndex((a) => areEqual(a, renderAsset));
|
|
22110
|
-
if (index === -1) {
|
|
22111
|
-
return false;
|
|
22112
|
-
}
|
|
22113
|
-
target.splice(index, 1);
|
|
22114
|
-
return true;
|
|
22115
|
-
};
|
|
22116
|
-
var copyAndDeduplicateAssets = (renderAssets) => {
|
|
22105
|
+
var deduplicateAssets = (renderAssets) => {
|
|
22117
22106
|
const onlyAudioAndVideo = onlyAudioAndVideoAssets(renderAssets);
|
|
22107
|
+
const seenIds = new Set;
|
|
22118
22108
|
const deduplicated = [];
|
|
22119
22109
|
for (const renderAsset of onlyAudioAndVideo) {
|
|
22120
|
-
if (!
|
|
22110
|
+
if (!seenIds.has(renderAsset.id)) {
|
|
22111
|
+
seenIds.add(renderAsset.id);
|
|
22121
22112
|
deduplicated.push(renderAsset);
|
|
22122
22113
|
}
|
|
22123
22114
|
}
|
|
22124
22115
|
return deduplicated;
|
|
22125
22116
|
};
|
|
22117
|
+
var indexUncompressedAssets = (renderAssets) => {
|
|
22118
|
+
const referencedAssets = new Set;
|
|
22119
|
+
for (const renderAsset of renderAssets) {
|
|
22120
|
+
if (renderAsset.src.startsWith("same-as")) {
|
|
22121
|
+
referencedAssets.add(renderAsset.src);
|
|
22122
|
+
}
|
|
22123
|
+
}
|
|
22124
|
+
const assetsByReference = new Map;
|
|
22125
|
+
for (const renderAsset of renderAssets) {
|
|
22126
|
+
if (referencedAssets.size === 0) {
|
|
22127
|
+
break;
|
|
22128
|
+
}
|
|
22129
|
+
if (renderAsset.src.startsWith("same-as")) {
|
|
22130
|
+
continue;
|
|
22131
|
+
}
|
|
22132
|
+
const reference = `same-as-${renderAsset.id}-${renderAsset.frame}`;
|
|
22133
|
+
if (referencedAssets.has(reference)) {
|
|
22134
|
+
assetsByReference.set(reference, renderAsset);
|
|
22135
|
+
referencedAssets.delete(reference);
|
|
22136
|
+
}
|
|
22137
|
+
}
|
|
22138
|
+
return assetsByReference;
|
|
22139
|
+
};
|
|
22126
22140
|
var calculateAssetPositions = (frames) => {
|
|
22127
22141
|
const assets = [];
|
|
22142
|
+
const openAssets = new Map;
|
|
22128
22143
|
const flattened = frames.flat(1);
|
|
22144
|
+
const uncompressedAssets = indexUncompressedAssets(flattened);
|
|
22129
22145
|
for (let frame = 0;frame < frames.length; frame++) {
|
|
22130
|
-
const
|
|
22131
|
-
const
|
|
22132
|
-
const
|
|
22146
|
+
const current = deduplicateAssets(frames[frame]);
|
|
22147
|
+
const currentIds = new Set(current.map((a) => a.id));
|
|
22148
|
+
for (const [id, openAsset] of openAssets) {
|
|
22149
|
+
if (!currentIds.has(id)) {
|
|
22150
|
+
openAsset.duration = frame - openAsset.startInVideo;
|
|
22151
|
+
openAssets.delete(id);
|
|
22152
|
+
}
|
|
22153
|
+
}
|
|
22133
22154
|
for (const asset of current) {
|
|
22134
|
-
|
|
22135
|
-
|
|
22136
|
-
|
|
22155
|
+
let openAsset = openAssets.get(asset.id);
|
|
22156
|
+
if (openAsset === undefined) {
|
|
22157
|
+
const uncompressedAsset = uncompressedAssets.get(asset.src);
|
|
22158
|
+
openAsset = {
|
|
22159
|
+
src: resolveAssetSrc(uncompressMediaAsset(uncompressedAsset ? [uncompressedAsset] : flattened, asset).src),
|
|
22137
22160
|
type: asset.type,
|
|
22138
22161
|
duration: null,
|
|
22139
22162
|
id: asset.id,
|
|
@@ -22144,17 +22167,16 @@ var calculateAssetPositions = (frames) => {
|
|
|
22144
22167
|
toneFrequency: asset.toneFrequency,
|
|
22145
22168
|
audioStartFrame: asset.audioStartFrame,
|
|
22146
22169
|
audioStreamIndex: asset.audioStreamIndex
|
|
22147
|
-
}
|
|
22148
|
-
|
|
22149
|
-
|
|
22150
|
-
if (!found)
|
|
22151
|
-
throw new Error("something wrong");
|
|
22152
|
-
if (!findFrom(next, asset)) {
|
|
22153
|
-
found.duration = frame - found.startInVideo + 1;
|
|
22170
|
+
};
|
|
22171
|
+
assets.push(openAsset);
|
|
22172
|
+
openAssets.set(asset.id, openAsset);
|
|
22154
22173
|
}
|
|
22155
|
-
|
|
22174
|
+
openAsset.volume.push(asset.volume);
|
|
22156
22175
|
}
|
|
22157
22176
|
}
|
|
22177
|
+
for (const openAsset of openAssets.values()) {
|
|
22178
|
+
openAsset.duration = frames.length - openAsset.startInVideo;
|
|
22179
|
+
}
|
|
22158
22180
|
for (const asset of assets) {
|
|
22159
22181
|
if (asset.duration === null) {
|
|
22160
22182
|
throw new Error("duration is unexpectedly null");
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/renderer"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/renderer",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.490",
|
|
7
7
|
"description": "Render Remotion videos using Node.js or Bun",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"execa": "5.1.1",
|
|
25
|
-
"remotion": "4.0.
|
|
26
|
-
"@remotion/streaming": "4.0.
|
|
25
|
+
"remotion": "4.0.490",
|
|
26
|
+
"@remotion/streaming": "4.0.490",
|
|
27
27
|
"source-map": "0.8.0-beta.0",
|
|
28
28
|
"ws": "8.21.0",
|
|
29
|
-
"@remotion/licensing": "4.0.
|
|
29
|
+
"@remotion/licensing": "4.0.490"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": ">=16.8.0",
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"react-dom": "19.2.3",
|
|
41
41
|
"@typescript/native-preview": "7.0.0-dev.20260217.1",
|
|
42
42
|
"@types/ws": "8.5.10",
|
|
43
|
-
"@remotion/example-videos": "4.0.
|
|
44
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
43
|
+
"@remotion/example-videos": "4.0.490",
|
|
44
|
+
"@remotion/eslint-config-internal": "4.0.490",
|
|
45
45
|
"eslint": "9.19.0",
|
|
46
46
|
"@types/node": "20.12.14"
|
|
47
47
|
},
|
|
48
48
|
"optionalDependencies": {
|
|
49
|
-
"@remotion/compositor-darwin-arm64": "4.0.
|
|
50
|
-
"@remotion/compositor-darwin-x64": "4.0.
|
|
51
|
-
"@remotion/compositor-linux-arm64-gnu": "4.0.
|
|
52
|
-
"@remotion/compositor-linux-arm64-musl": "4.0.
|
|
53
|
-
"@remotion/compositor-linux-x64-gnu": "4.0.
|
|
54
|
-
"@remotion/compositor-linux-x64-musl": "4.0.
|
|
55
|
-
"@remotion/compositor-win32-x64-msvc": "4.0.
|
|
49
|
+
"@remotion/compositor-darwin-arm64": "4.0.490",
|
|
50
|
+
"@remotion/compositor-darwin-x64": "4.0.490",
|
|
51
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.490",
|
|
52
|
+
"@remotion/compositor-linux-arm64-musl": "4.0.490",
|
|
53
|
+
"@remotion/compositor-linux-x64-gnu": "4.0.490",
|
|
54
|
+
"@remotion/compositor-linux-x64-musl": "4.0.490",
|
|
55
|
+
"@remotion/compositor-win32-x64-msvc": "4.0.490"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|
|
58
58
|
"remotion",
|