Skip to main content

入口点

入口点是 Remotion CLI@remotion/renderer API 将用于查找 Remotion 项目的文件。

🌐 The entry point is the file where the Remotion CLI and @remotion/renderer APIs will look for a Remotion project.

  • 在大多数模板中,默认是 src/index.ts
  • 在较旧的项目中,它可能有一个 .tsx 扩展名,而不是 .ts
  • 入口点可以传递给渲染命令,例如:npx remotion render src/index.ts
  • 入口点应该调用 registerRoot()
  • 如果你使用 npx remotion render 渲染视频,入口点会以灰色显示。
  • 你可以使用 Config.setEntryPoint() 在配置文件中自定义默认入口点。

正在使用哪个入口点?

🌐 Which entry point is being used?

如果你调用 npx remotion render,将会打印出入口点以及选择它的原因。算法如下:

🌐 If you call npx remotion render, the entry point and the reason why it was chosen will be printed. The algorithm is as follows:

如果直接传入入口点,例如 npx remotion render src/index.ts,请使用它。
2
否则,如果在 配置文件 中使用 Config.setEntryPoint()指定了路径,请使用它。
3
检查以下常见路径,如果存在其中之一,请使用它:

  • src/index.ts
  • src/index.tsx
  • src/index.js
  • src/index.mjs
  • remotion/index.tsx
  • remotion/index.ts
  • remotion/index.js
  • remotion/index.mjs
  • src/remotion/index.tsx
  • src/remotion/index.ts
  • src/remotion/index.js
  • src/remotion/index.mjs

在播放器中

🌐 In the Player

Remotion Player 中,没有入口点的概念。 你直接将一个 React 组件和元数据传递给 <Player>

🌐 In the Remotion Player, there is no concept of an entry point.
You directly pass a React component and metadata to the <Player>.