packages/docs/docs/renderer/stitch-frames-to-video.mdx
Part of the @remotion/renderer package.
Takes a series of images and audio information generated by renderFrames() and encodes it to a video.
:::info
In Remotion 3.0, we added the renderMedia() API which combines renderFrames() and stitchFramesToVideo() into one simplified step and performs the render faster. Prefer renderMedia() if you can.
:::
An object with the following properties:
fpsA number specifying the desired frame rate of the output video.
widthA number specifying the desired output width in pixels for the video.
heightA number specifying the desired output height in pixels for the video.
metadata<AvailableFrom v="4.0.216" />object
<Options id="metadata" />assetsInfoInformation about the frames and audio mix. This is part of the return value of renderFrames().
The data structure is not stable between Remotion versions.
outputLocation?An absolute path specify where the output file should be written to.
If not specified or set to null, the file will be returned in-memory as a buffer.
force?Whether Remotion should overwrite the file in outputLocation if it already exists. true by default.
pixelFormat?Sets the pixel format. See here for available values. The default is yuv420p.
codec?Set a codec. See the encoding guide for available values and guidance on which one to choose. The default is h264.
audioCodec?<AvailableFrom v="3.3.41" />"pcm-16" | "aac" | "mp3" | "opus"
Choose the encoding of your audio.
codec.pcm-16 if you need uncompressed audio.codec option also specifies an audio codec.Refer to the Encoding guide to see defaults and supported combinations.
audioBitrate?<AvailableFrom v="3.2.32" />videoBitrate?<AvailableFrom v="3.2.32" />bufferSize?<AvailableFrom v="4.0.78" />maxRate?<AvailableFrom v="4.0.78" />crf?The constant rate factor of the output, a parameter which controls quality. See here for more information about this parameter. Default is depending on the codec.
proResProfile?Sets a ProRes profile. Only applies to videos rendered with prores codec. See Encoding guide for possible options.
onProgress?Callback function which informs about the encoding progress. The frameNumber value is a number.
const onProgress = (frameNumber: number) => {
console.log(`Encoding progress: on ${frameNumber} frame`);
};
onDownload?Notifies when a remote asset needs to be downloaded in order to extract the audio track.
const onDownload = (src: string) => {
console.log(`Downloading ${src}...`);
};
numberOfGifLoops?<AvailableFrom v="3.1.0" />muted?<AvailableFrom v="3.2.1" />Disables audio output. This option may only be set in combination with a video codec and should also be passed to renderFrames().
hardwareAcceleration?<AvailableFrom v="4.0.228" />verbose?A boolean value that when set to true, will log all kinds of debug information. Default false.
cancelSignal?<AvailableFrom v="3.0.15" />A token that allows the render to be cancelled. See: makeCancelSignal()
enforceAudioTrack?<AvailableFrom v="3.2.1" />Render a silent audio track if there wouldn't be any otherwise.
binariesDirectory?<AvailableFrom v="4.0.120" />separateAudioTo?<AvailableFrom v="4.0.123" />forSeamlessAacConcatenation?<AvailableFrom v="4.0.123" />x264Preset?gopSize?<AvailableFrom v="4.0.466" />colorSpace?<AvailableFrom v="4.0.28"/>ffmpegOverride?<AvailableFrom v="3.2.22" />Modifies the FFMPEG command that Remotion uses under the hood. It works reducer-style, meaning that you pass a function that takes a command as an argument and returns a new command.
import type {FfmpegOverrideFn} from '@remotion/renderer';
const ffmpegOverride: FfmpegOverrideFn = ({type, args}) => {
console.log(type); // "stitcher" | "pre-stitcher
return [...args, '-vf', 'eq=brightness=0:saturation=1'];
};
The function you pass must accept an object as it's only parameter which contains the following properties:
type: Either "stitcher" or "pre-stitcher". If enough memory and CPU is available, Remotion may use a two-pass process for the video generation. pre-stitcher is the encoding phase and stitcher is the muxing phase. If the override function is only called once with stitcher, then encoding and muxing is done in the same step. You can tell whether parallel encoding is enabled by adding --log=verbose to your render command.args: An array of strings that is passed as arguments to the FFMPEG command.Your function must return a modified array of strings.
:::warning Using this feature is discouraged. Before using it, we want to make you aware of some caveats:
Before you use this hack, reach out to the Remotion team on Discord and ask us if we are open to implement the feature you need in a clean way - we often do implement new features quickly based on users feedback. :::
ffmpegExecutableremoved in v4.0
A custom FFMPEG executable to be used. By default, a binary called ffmpeg will be searched in your PATH.
ffprobeExecutable?removed in v4.0
An absolute path overriding the ffprobe executable to use.
stitchFramesToVideo() returns a promise which resolves to nothing. If everything goes well, the output will be placed in outputLocation.