Skip to content

🎥 Make videos programmatically with React

simplify

Jonny Burger6961ff58fa9f
diff --git a/packages/docs/docs/video-manipulation.md b/packages/docs/docs/video-manipulation.md
index 0f779a70ea..446db9b74d 100644
--- a/packages/docs/docs/video-manipulation.md
+++ b/packages/docs/docs/video-manipulation.md
@@ -5,7 +5,7 @@ title: Video manipulation
import { VideoCanvasExamples } from "../components/GreenscreenExamples/index";
-You can manipulate a video buffer by rendering a `<Video>`
+You can manipulate a video buffer by rendering a [`<Video>`](/docs/video) onto a `<canvas>` element using the [`drawImage()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage) API and keeping it in sync using [`requestVideoFrameCallback`](https://blog.tomayac.com/2020/05/15/the-requestvideoframecallback-api/).
## Basic example
@@ -13,6 +13,10 @@ You can manipulate a video buffer by rendering a `<Video>`
<br/>
```tsx twoslash
+import { useVideoConfig, Video } from "remotion";
+import { useCallback, useEffect, useRef } from "react";
+import React from "react";
+import { AbsoluteFill } from "remotion";
declare global {
interface VideoFrameMetadata {
presentationTime: DOMHighResTimeStamp;
@@ -35,11 +39,6 @@ declare global {
}
}
// ---cut---
-import { useVideoConfig, Video } from "remotion";
-import { useCallback, useEffect, useRef } from "react";
-import React from "react";
-import { AbsoluteFill } from "remotion";
-
export const VideoOnCanvas: React.FC = () => {
const video = useRef<HTMLVideoElement>(null);
const canvas = useRef<HTMLCanvasElement>(null);
@@ -99,7 +98,7 @@ export const VideoOnCanvas: React.FC = () => {
};
```
-## Video manipulation example - Greenscreen
+## Greenscreen example
<VideoCanvasExamples type="greenscreen"/>
<br/>
diff --git a/packages/docs/package.json b/packages/docs/package.json
index 974ffed0a6..4f7b7324e4 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -48,7 +48,6 @@
"@types/jest": "^27.4.0",
"@types/node": "^17.0.17",
"@types/react": "17.0.39",
- "@typescript/lib-dom": "npm:@types/web@^0.0.53",
"eslint": "^7.25.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 836298bb3f..3c96e84760 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -273,7 +273,6 @@ importers:
'@types/jest': ^27.4.0
'@types/node': ^17.0.17
'@types/react': 17.0.39
- '@typescript/lib-dom': npm:@types/web@^0.0.53
chalk: 4.1.2
clipboard: ^2.0.8
clsx: ^1.1.1
@@ -323,7 +322,6 @@ importers:
'@types/jest': 27.4.0
'@types/node': 17.0.17
'@types/react': 17.0.39
- '@typescript/lib-dom': /@types/web/0.0.53
eslint: 7.32.0
react: 17.0.2
react-dom: [email protected]
@@ -7073,10 +7071,6 @@ packages:
resolution: {integrity: sha512-X5KKfR0MNm5ujo7421tVTF6n9MXh58DfWOuvPnuMAlr12vloTtyxJEC0rHVKIvcpqqoOJSrlkW2dMJjl9eK3Dg==}
dev: false
- /@types/web/0.0.53:
- resolution: {integrity: sha512-ULJJgHevSiiD/QaSWcpAfWHXHEaeXUXGGJ82XVderV4TAWdI22NFyjWcRfzJwjEIdUi0gvfVRlTFDeLTZpvF4Q==}
- dev: true
-
/@types/webpack-env/1.16.2:
resolution: {integrity: sha512-vKx7WNQNZDyJveYcHAm9ZxhqSGLYwoyLhrHjLBOkw3a7cT76sTdjgtwyijhk1MaHyRIuSztcVwrUOO/NEu68Dw==}
dev: true