Capítulo 153 de 988
:::info This documentation is how server-side rendering worked in Remotion v1 and Remotion v2. To see rendering in 3.
import {
getCompositions,
renderFrames,
stitchFramesToVideo,
} from "@remotion/renderer";
const start = async () => {
// The composition you want to render
const compositionId = "HelloWorld";
// Create a webpack bundle of the entry file.
const bundleLocation = await bundle(require.resolve("./src/index.ts"));
// Extract all the compositions you have defined in your project
// from the webpack bundle.
const comps = await getCompositions(bundleLocation, {
// You can pass custom input props that you can retrieve using getInputProps()
// in the composition list. Use this if you want to dynamically set the duration or
// dimensions of the video.
inputProps: {
custom: "data",
},
});
// Select the composition you want to render.
const composition = comps.find((c) => c.id === compositionId);
// Ensure the composition exists
if (!composition) {
throw new Error(`No composition with the ID ${compositionId} found`);
}
// We create a temporary directory for storing the frames
const framesDir = await fs.promises.mkdtemp(
path.join(os.tmpdir(), "remotion-"),
);
// We create JPEGs for all frames
const { assetsInfo } = await renderFrames({
config: composition,
// Path of the webpack bundle you have created
bundle: bundleLocation,
// Get's called after bundling is finished and the
// actual rend
// ...(truncated)