Skip to content

Commit 725fa4d

Browse files
committed
Update playground to reproduce many clips performance issue
- Change imports from core-v4 to core in all playground files - Replace single animated video clip with multiple clips using sequential layer - Split 20-second video into 50 clips with 4-second minimum duration each - Use sliding window approach where clips overlap to maintain minimum duration - Skip clips that would exceed video duration - This setup helps reproduce browser hanging issue when adding many clips
1 parent 4e784a7 commit 725fa4d

File tree

5 files changed

+27
-47
lines changed

5 files changed

+27
-47
lines changed

playground/composition.ts

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as core from '@diffusionstudio/core-v4';
1+
import * as core from '@diffusionstudio/core';
22

33
export const settings: core.CompositionSettings = {
44
background: '#76b7f5',
@@ -22,49 +22,29 @@ export async function main(composition: core.Composition) {
2222
core.Source.from<core.ImageSource>('/parrot.jpg')
2323
]);
2424

25-
const mask = new core.RectangleMask({
26-
x: 1920 / 2,
27-
y: 1080 / 2,
28-
width: 1080,
29-
height: 1080,
30-
radius: 100,
31-
});
32-
33-
const videoClip = new core.VideoClip(sources[0], {
34-
position: 'center',
35-
mask,
36-
height: '100%',
37-
animations: [
38-
{
39-
key: 'scale',
40-
frames: [
41-
{ time: 0, value: 0.5 },
42-
{ time: 2, value: 1 },
43-
],
44-
},
45-
{
46-
key: 'rotation',
47-
frames: [
48-
{ time: 0, value: 0 },
49-
{ time: 2, value: 720 },
50-
],
51-
},
52-
{
53-
key: 'opacity',
54-
frames: [
55-
{ time: 0, value: 100 },
56-
{ time: 1, value: 80 },
57-
{ time: 2, value: 100 },
58-
],
59-
}
60-
],
61-
range: [0.8, 18],
62-
delay: 1,
63-
})
25+
const CLIPS = 50;
26+
const videoDuration = 20;
27+
const minClipDuration = 4;
28+
const slideStep = videoDuration / CLIPS;
6429

65-
const videoLayer = new core.Layer();
30+
const videoLayer = new core.Layer({ mode: 'SEQUENTIAL' });
6631
await composition.add(videoLayer);
67-
await videoLayer.add(videoClip);
32+
33+
for (let i = 0; i < CLIPS; i++) {
34+
const startTime = i * slideStep;
35+
const endTime = startTime + minClipDuration;
36+
37+
if (endTime > videoDuration) continue;
38+
39+
const videoClip = new core.VideoClip(sources[0], {
40+
position: 'center',
41+
height: '100%',
42+
range: [startTime, endTime],
43+
duration: minClipDuration,
44+
});
45+
46+
await videoLayer.add(videoClip);
47+
}
6848

6949
const imageClip = new core.ImageClip(sources[1], {
7050
position: 'center',

playground/controls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as core from '@diffusionstudio/core-v4';
1+
import * as core from '@diffusionstudio/core';
22
import { render } from './render';
33

44
export function setupControls(composition: core.Composition) {

playground/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as core from '@diffusionstudio/core-v4';
1+
import * as core from '@diffusionstudio/core';
22
import { setupControls } from './controls';
33
import { setupTimeline } from './timeline';
44
import { main, settings } from './composition';

playground/render.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as core from '@diffusionstudio/core-v4';
1+
import * as core from '@diffusionstudio/core';
22

33
let fps = 30;
44

playground/timeline.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as core from '@diffusionstudio/core-v4';
1+
import * as core from '@diffusionstudio/core';
22

33
export function setupTimeline(composition: core.Composition) {
44
composition.on('playback:time', () => {
@@ -26,4 +26,4 @@ export function setupTimeline(composition: core.Composition) {
2626
}
2727

2828
const timeline = document.querySelector('[id="timeline"]') as HTMLDivElement;
29-
const cursor = document.querySelector('[id="timeline"] > div') as HTMLDivElement;
29+
const cursor = document.querySelector('[id="timeline"] > div') as HTMLDivElement;

0 commit comments

Comments
 (0)