Skip to content

🎥 Make videos programmatically with React

this makes a lot of sense

Jonny Burgerd0d127e6c516
diff --git a/packages/studio/src/components/Timeline/TimelineVideoInfo.tsx b/packages/studio/src/components/Timeline/TimelineVideoInfo.tsx
index 666fb14065..25d4d2c368 100644
--- a/packages/studio/src/components/Timeline/TimelineVideoInfo.tsx
+++ b/packages/studio/src/components/Timeline/TimelineVideoInfo.tsx
@@ -274,6 +274,8 @@ export const TimelineVideoInfo: React.FC<{
return;
}
+ const controller = new AbortController();
+
const canvas = document.createElement('canvas');
canvas.width = visualizationWidth;
canvas.height = HEIGHT;
@@ -282,6 +284,8 @@ export const TimelineVideoInfo: React.FC<{
return;
}
+ current.appendChild(canvas);
+
// desired-timestamp -> filled-timestamp
const filledSlots = new Map<number, number | undefined>();
@@ -305,13 +309,18 @@ export const TimelineVideoInfo: React.FC<{
segmentDuration: toSeconds - fromSeconds,
fromSeconds,
});
- }
- clearOldFrames();
+ const unfilled = Array.from(filledSlots.keys()).filter(
+ (timestamp) => !filledSlots.get(timestamp),
+ );
- current.appendChild(canvas);
+ // Don't extract frames if all slots are filled
+ if (unfilled.length === 0) {
+ return;
+ }
+ }
- const controller = new AbortController();
+ clearOldFrames();
extractFrames({
acknowledgeRemotionLicense: true,