Skip to main content

makeCancelSignal()v3.0.15

@remotion/renderer 包的一部分.

🌐 Part of the @remotion/renderer package.

此函数返回一个信号和一个取消函数,允许你取消使用 renderMedia()renderStill()renderFrames()stitchFramesToVideo() 触发的渲染。

🌐 This function returns a signal and a cancel function that allows to you cancel a render triggered using renderMedia(), renderStill(), renderFrames() or stitchFramesToVideo() .

示例

🌐 Example

import {makeCancelSignal, renderMedia} from '@remotion/renderer';

const {cancelSignal, cancel} = makeCancelSignal();

// Note that no `await` is used yet
const render = renderMedia({
  composition,
  codec: 'h264',
  serveUrl: '/path/to/bundle',
  outputLocation: 'out/render.mp4',
  cancelSignal,
});

// Cancel render after 10 seconds
setTimeout(() => {
  cancel();
}, 10000);

// If the render completed within 10 seconds, renderMedia() will resolve
await render;

// If the render did not complete, renderMedia() will reject
// ==> "[Error: renderMedia() got cancelled]"

应用编程接口

🌐 API

调用 makeCancelSignal 会返回一个具有两个属性的对象:

🌐 Calling makeCancelSignal returns an object with two properties:

  • cancelSignal:要传递给上述渲染函数之一的对象
  • cancel:当你想取消渲染时应该调用的函数。

兼容性

🌐 Compatibility

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

另请参阅

🌐 See also