将 a <Player> 转变为 Remotion 项目
如果你有一个使用 <Player> 组件的 React 应用,你也可以将其转换为 Remotion 项目,而不必创建新的仓库。这将使你能够:
🌐 If you have a React app that uses the <Player> component, you can turn it also into a Remotion project without having to create a new repository. This will enable you to:
说明
🌐 Instructions
确保你还没有安装 Studio——在以下模板中,Studio 已经安装好,可以使用命令npx remotion studio
启动:- Next.js(应用目录)
- Next.js(应用目录,无 TailwindCSS)
- Next.js(页面目录)
- Next.js(应用目录,在 Vercel 沙箱中渲染)
- React Router 7 (Remix)
- npm
- bun
- pnpm
- yarn
This assumes you are currently using v4.0.431 of Remotion.npm i --save-exact @remotion/cli@4.0.431
Also update
remotion and all `@remotion/*` packages to the same version.Remove all
^ character in front of the version numbers of it as it can lead to a version conflict.This assumes you are currently using v4.0.431 of Remotion.pnpm i @remotion/cli@4.0.431
Also update
remotion and all `@remotion/*` packages to the same version.Remove all
^ character in front of the version numbers of it as it can lead to a version conflict.This assumes you are currently using v4.0.431 of Remotion.bun i @remotion/cli@4.0.431
Also update
remotion and all `@remotion/*` packages to the same version.Remove all
^ character in front of the version numbers of it as it can lead to a version conflict.This assumes you are currently using v4.0.431 of Remotion.yarn --exact add @remotion/cli@4.0.431
Also update
remotion and all `@remotion/*` packages to the same version.Remove all
^ character in front of the version numbers of it as it can lead to a version conflict.创建一个新的文件夹
remotion 并将这两个文件添加到其中:
remotion/Root.tsximportReact from 'react'; import {Composition } from 'remotion'; import {MyComposition } from './Composition'; export constRemotionRoot :React .FC = () => { return ( <> <Composition id ="Empty" // Import the component and add the properties you had in the `<Player>` beforecomponent ={MyComposition }durationInFrames ={60}fps ={30}width ={1280}height ={720} /> </> ); };
remotion/index.tsimport {registerRoot } from "remotion"; import {RemotionRoot } from "./Root";registerRoot (RemotionRoot );
将你之前在 <Player> 中注册的组件也添加到 <Composition> 中。
如有必要,将组件移动到 remotion 目录中。
调用 registerRoot() 的文件现在是你的 Remotion 入口点。
🌐 The file that calls registerRoot() is now your Remotion entry point.
启动 Remotion Studio:
🌐 Start the Remotion Studio:
npx remotion studio渲染视频
🌐 Render a video
使用渲染我们的视频
🌐 Render our a video using
npx remotion render remotion/index.ts设置服务器端渲染
🌐 Set up server-side rendering
有关更多信息,请参阅服务器端渲染。
🌐 See server-side rendering for more information.
我如何从 Remotion 播放器下载视频?
🌐 How do I download a video from the Remotion Player?
视频首先需要进行渲染——这只能在服务器上完成。有关更多信息,请参见渲染的方法和服务器端渲染。
🌐 The video first needs to get rendered - this can only be done on the server. See ways to render and server-side rendering for more information.