@bendyline/squisq-video 2.4.21 → 2.4.22
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/index.js +40 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -66,6 +66,7 @@ function resolveFfmpegWasmLoad(config, context, defaults) {
|
|
|
66
66
|
// src/audioTimeline.ts
|
|
67
67
|
import { resolveMediaSchedule } from "@bendyline/squisq/schemas";
|
|
68
68
|
import { flattenRenderableBlocks, materializeBlockLayers } from "@bendyline/squisq/doc";
|
|
69
|
+
import { createMediaTimeMap } from "@bendyline/squisq/mediaEdit";
|
|
69
70
|
var CUT_EDGE_FADE_SEC = 0.01;
|
|
70
71
|
function clipDynamics(clip) {
|
|
71
72
|
const out = {};
|
|
@@ -124,22 +125,47 @@ function computeAudioTimeline(doc, coverPreRoll = 0, options = {}) {
|
|
|
124
125
|
for (const layer of materialized.layers) {
|
|
125
126
|
if (layer.type !== "video" || !layer.content.src) continue;
|
|
126
127
|
const startAt = safeSeconds(layer.content.startAt ?? 0);
|
|
127
|
-
const
|
|
128
|
-
const clipDuration = Math.max(0, layer.content.clipEnd - sourceInSec);
|
|
128
|
+
const clipStart = safeSeconds(layer.content.clipStart);
|
|
129
129
|
const blockRemainder = Math.max(0, safeSeconds(block.duration) - startAt);
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
const kept = createMediaTimeMap({
|
|
131
|
+
clipStart,
|
|
132
|
+
clipEnd: Math.max(clipStart, layer.content.clipEnd),
|
|
133
|
+
cuts: layer.content.cuts
|
|
134
|
+
}).keptRanges();
|
|
135
|
+
const edits = layer.content.edits;
|
|
136
|
+
const processed = edits?.fx && options.processedAudio ? options.processedAudio({
|
|
137
|
+
id: layer.id,
|
|
133
138
|
src: layer.content.src,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
kind: "video",
|
|
140
|
+
startAt: 0,
|
|
141
|
+
anchor: "block",
|
|
142
|
+
edits
|
|
143
|
+
}) : void 0;
|
|
144
|
+
let played = 0;
|
|
145
|
+
kept.forEach((range, index) => {
|
|
146
|
+
const length = range.end - range.start;
|
|
147
|
+
const room = layer.content.spillover ? length : Math.min(length, blockRemainder - played);
|
|
148
|
+
const offset = played;
|
|
149
|
+
played += length;
|
|
150
|
+
if (!(room > 0)) return;
|
|
151
|
+
const fadeIn = index > 0 ? CUT_EDGE_FADE_SEC : edits?.fadeIn ?? 0;
|
|
152
|
+
const fadeOut = index < kept.length - 1 ? CUT_EDGE_FADE_SEC : edits?.fadeOut ?? 0;
|
|
153
|
+
const candidate = {
|
|
154
|
+
src: processed ?? layer.content.src,
|
|
155
|
+
startSec: safeSeconds(block.startTime) + startAt + offset + preRoll,
|
|
156
|
+
sourceInSec: range.start,
|
|
157
|
+
durationSec: room,
|
|
158
|
+
// A render is an audio file; only the video itself may be silent.
|
|
159
|
+
...processed ? {} : { sourceKind: "video" },
|
|
160
|
+
...edits?.gain ? { gainDb: edits.gain } : {},
|
|
161
|
+
...fadeIn > 0 ? { fadeInSec: fadeIn } : {},
|
|
162
|
+
...fadeOut > 0 ? { fadeOutSec: fadeOut } : {}
|
|
163
|
+
};
|
|
164
|
+
const key = timelineKey(candidate);
|
|
165
|
+
if (existing.has(key)) return;
|
|
166
|
+
existing.add(key);
|
|
167
|
+
clips.push(candidate);
|
|
168
|
+
});
|
|
143
169
|
}
|
|
144
170
|
});
|
|
145
171
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/squisq-video",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.22",
|
|
4
4
|
"description": "Cross-runtime video and animated-GIF helpers with browser-based ffmpeg.wasm encoding for Squisq documents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bendyline",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@bendyline/squisq": "2.13.
|
|
51
|
+
"@bendyline/squisq": "2.13.16",
|
|
52
52
|
"@ffmpeg/ffmpeg": "0.12.15",
|
|
53
53
|
"@ffmpeg/util": "0.12.2"
|
|
54
54
|
},
|