@remotion/studio 4.0.441 → 4.0.442
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/components/AudioWaveform.js +67 -61
- package/dist/components/Editor.js +7 -4
- package/dist/components/EditorGuides/Guide.js +2 -1
- package/dist/components/EditorRuler/Ruler.js +2 -1
- package/dist/components/EditorRuler/index.js +4 -7
- package/dist/components/ForceSpecificCursor.d.ts +3 -0
- package/dist/components/ForceSpecificCursor.js +68 -0
- package/dist/components/NewComposition/InputDragger.js +3 -0
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +10 -3
- package/dist/components/Splitter/SplitterHandle.js +3 -0
- package/dist/components/Timeline/Timeline.js +3 -3
- package/dist/components/Timeline/TimelineDragHandler.js +4 -0
- package/dist/components/Timeline/TimelineWidthProvider.js +16 -1
- package/dist/components/draw-peaks.d.ts +1 -0
- package/dist/components/draw-peaks.js +61 -0
- package/dist/components/load-waveform-peaks.d.ts +3 -0
- package/dist/components/load-waveform-peaks.js +67 -0
- package/dist/components/parse-color.d.ts +1 -0
- package/dist/components/parse-color.js +17 -0
- package/dist/esm/{chunk-1x2ychmc.js → chunk-j8c13fkw.js} +1898 -1743
- package/dist/esm/internals.mjs +1898 -1743
- package/dist/esm/previewEntry.mjs +1879 -1724
- package/dist/esm/renderEntry.mjs +1 -1
- package/dist/helpers/calculate-timeline.d.ts +1 -2
- package/dist/helpers/calculate-timeline.js +2 -23
- package/package.json +9 -9
- package/dist/components/AudioWaveformBar.d.ts +0 -14
- package/dist/components/AudioWaveformBar.js +0 -33
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TARGET_SAMPLE_RATE = void 0;
|
|
4
|
+
exports.loadWaveformPeaks = loadWaveformPeaks;
|
|
5
|
+
const mediabunny_1 = require("mediabunny");
|
|
6
|
+
const TARGET_SAMPLE_RATE = 100;
|
|
7
|
+
exports.TARGET_SAMPLE_RATE = TARGET_SAMPLE_RATE;
|
|
8
|
+
const peaksCache = new Map();
|
|
9
|
+
async function loadWaveformPeaks(url, signal) {
|
|
10
|
+
const cached = peaksCache.get(url);
|
|
11
|
+
if (cached)
|
|
12
|
+
return cached;
|
|
13
|
+
const input = new mediabunny_1.Input({
|
|
14
|
+
formats: mediabunny_1.ALL_FORMATS,
|
|
15
|
+
source: new mediabunny_1.UrlSource(url),
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
const audioTrack = await input.getPrimaryAudioTrack();
|
|
19
|
+
if (!audioTrack) {
|
|
20
|
+
return new Float32Array(0);
|
|
21
|
+
}
|
|
22
|
+
const { sampleRate } = audioTrack;
|
|
23
|
+
const durationInSeconds = await audioTrack.computeDuration();
|
|
24
|
+
const totalPeaks = Math.ceil(durationInSeconds * TARGET_SAMPLE_RATE);
|
|
25
|
+
const samplesPerPeak = Math.floor(sampleRate / TARGET_SAMPLE_RATE);
|
|
26
|
+
const peaks = new Float32Array(totalPeaks);
|
|
27
|
+
let peakIndex = 0;
|
|
28
|
+
let peakMax = 0;
|
|
29
|
+
let sampleInPeak = 0;
|
|
30
|
+
const sink = new mediabunny_1.AudioSampleSink(audioTrack);
|
|
31
|
+
for await (const sample of sink.samples()) {
|
|
32
|
+
if (signal.aborted) {
|
|
33
|
+
sample.close();
|
|
34
|
+
return new Float32Array(0);
|
|
35
|
+
}
|
|
36
|
+
const bytesNeeded = sample.allocationSize({
|
|
37
|
+
format: 'f32',
|
|
38
|
+
planeIndex: 0,
|
|
39
|
+
});
|
|
40
|
+
const floats = new Float32Array(bytesNeeded / 4);
|
|
41
|
+
sample.copyTo(floats, { format: 'f32', planeIndex: 0 });
|
|
42
|
+
sample.close();
|
|
43
|
+
for (let i = 0; i < floats.length; i++) {
|
|
44
|
+
const abs = Math.abs(floats[i]);
|
|
45
|
+
if (abs > peakMax)
|
|
46
|
+
peakMax = abs;
|
|
47
|
+
sampleInPeak++;
|
|
48
|
+
if (sampleInPeak >= samplesPerPeak) {
|
|
49
|
+
if (peakIndex < totalPeaks) {
|
|
50
|
+
peaks[peakIndex] = peakMax;
|
|
51
|
+
}
|
|
52
|
+
peakIndex++;
|
|
53
|
+
peakMax = 0;
|
|
54
|
+
sampleInPeak = 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (sampleInPeak > 0 && peakIndex < totalPeaks) {
|
|
59
|
+
peaks[peakIndex] = peakMax;
|
|
60
|
+
}
|
|
61
|
+
peaksCache.set(url, peaks);
|
|
62
|
+
return peaks;
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
input.dispose();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseColor: (color: string) => [number, number, number, number];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseColor = void 0;
|
|
4
|
+
const colorCache = new Map();
|
|
5
|
+
const parseColor = (color) => {
|
|
6
|
+
const cached = colorCache.get(color);
|
|
7
|
+
if (cached)
|
|
8
|
+
return cached;
|
|
9
|
+
const ctx = new OffscreenCanvas(1, 1).getContext('2d');
|
|
10
|
+
ctx.fillStyle = color;
|
|
11
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
12
|
+
const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data;
|
|
13
|
+
const result = [r, g, b, a];
|
|
14
|
+
colorCache.set(color, result);
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
exports.parseColor = parseColor;
|