makeCancelSignal()
Available from v3.0.15
This function returns a signal and a cancel function that allows to you cancel a render triggered using renderMedia()
, renderStill()
, renderFrames()
or stitchFramesToVideo()
.
Example
tsx
import {makeCancelSignal ,renderMedia } from "@remotion/renderer";const {cancelSignal ,cancel } =makeCancelSignal ();// Note that no `await` is used yetconstrender =renderMedia ({composition ,codec : "h264",serveUrl : "https://silly-crostata-c4c336.netlify.app/",outputLocation : "out/render.mp4",cancelSignal ,});// Cancel render after 10 secondssetTimeout (() => {cancel ();}, 10000);// If the render completed within 10 seconds, renderMedia() will resolveawaitrender ;// If the render did not complete, renderMedia() will reject// ==> "[Error: renderMedia() got cancelled]"
tsx
import {makeCancelSignal ,renderMedia } from "@remotion/renderer";const {cancelSignal ,cancel } =makeCancelSignal ();// Note that no `await` is used yetconstrender =renderMedia ({composition ,codec : "h264",serveUrl : "https://silly-crostata-c4c336.netlify.app/",outputLocation : "out/render.mp4",cancelSignal ,});// Cancel render after 10 secondssetTimeout (() => {cancel ();}, 10000);// If the render completed within 10 seconds, renderMedia() will resolveawaitrender ;// If the render did not complete, renderMedia() will reject// ==> "[Error: renderMedia() got cancelled]"
API
Calling makeCancelSignal
returns an object with two properties:
cancelSignal
: An object to be passed to one of the above mentioned render functionscancel
: A function you should call when you want to cancel the render.