-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathcomposition.ts
More file actions
36 lines (27 loc) · 981 Bytes
/
composition.ts
File metadata and controls
36 lines (27 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as core from '@diffusionstudio/core';
export const settings: core.CompositionSettings = {
background: '#76b7f5',
};
export async function main(composition: core.Composition) {
core.env.experimental_timeBase = 30;
core.env.experimental_canonicalTimeBase = 48_000;
const videoSource = await core.Source.from<core.VideoSource>('/bbb_1080p_30fps.mp4');
const CLIPS = 40;
const videoDuration = 20;
const minClipDuration = 3;
const slideStep = videoDuration / CLIPS;
const videoLayer = new core.Layer({ mode: 'SEQUENTIAL' });
await composition.add(videoLayer);
for (let i = 0; i < CLIPS; i++) {
const startTime = i * slideStep;
const endTime = startTime + minClipDuration;
if (endTime > videoDuration) continue;
const videoClip = new core.VideoClip(videoSource, {
position: 'center',
height: '100%',
range: [startTime, endTime],
duration: minClipDuration,
});
await videoLayer.add(videoClip);
}
}