Skip to main content

useVideoConfig()

使用这个钩子,你可以获取一些关于你所在作品的信息。

🌐 With this hook, you can retrieve some info about the composition you are in.

示例

🌐 Example

import React from 'react';
import {useVideoConfig} from 'remotion';

export const MyComp: React.FC = () => {
  const {width, height, fps, durationInFrames} = useVideoConfig();
  console.log(width); // 1920
  console.log(height); // 1080
  console.log(fps); // 30;
  console.log(durationInFrames); // 300

  return <div>Hello World!</div>;
};

返回值

🌐 Return value

一个具有以下属性的对象:

🌐 A object with the following properties:

width

构图的像素宽度,或者如果调用 useVideoConfig() 的组件是定义宽度的 <Sequence> 的子组件,则为 <Sequence>width

🌐 The width of the composition in pixels, or the width of a <Sequence> if the component that calls useVideoConfig() is a child of a <Sequence> that defines a width.

height

构图的高度(以像素为单位),或者如果调用 useVideoConfig() 的组件是定义高度的 <Sequence> 的子组件,则为 <Sequence>height

🌐 The height of the composition in pixels, or the height of a <Sequence> if the component that calls useVideoConfig() is a child of a <Sequence> that defines a height.

fps

构图的帧率,以每秒帧数表示。

🌐 The frame rate of the composition, in frames per seconds.

durationInFrames

如果在 <Sequence> 内,序列的持续时间以帧为单位。
如果不在 <Sequence> 内,合成的持续时间以帧为单位。

🌐 If inside a <Sequence>, the duration of the sequence in frames.
If not inside a <Sequence>, the duration of the composition in frames.

id

作品的 ID。这与 <Composition> 组件的 id 属性相同。

🌐 The ID of the composition. This is the same as the id prop of the <Composition> component.

defaultProps

你在作品中定义为 defaultProps 的对象。

🌐 The object that you have defined as the defaultProps in your composition.

propsv4.0.0

传递给组合的 props,在 所有变换 之后。

🌐 The props that were passed to the composition, after all transformations.

defaultCodecv4.0.54

用于渲染此合成的默认编解码器。使用 calculateMetadata() 来修改它。

🌐 The default codec that is used for rendering this composition. Use calculateMetadata() to modify it.

这些属性是通过将它们作为 props 传递给 <Composition> 来控制的。阅读关于 基础知识 的页面,了解如何设置 Remotion 项目。

🌐 These properties are controlled by passing them as props to <Composition>. Read the page about the fundamentals to read how to setup a Remotion project.

兼容性

🌐 Compatibility

BrowsersEnvironments
Chrome
Firefox
Safari

另请参阅

🌐 See also