packages/docs/docs/render-as-gif.mdx
Available since v3.1
You can render a video as a GIF by:
--codec=gif in the command linecodec: "gif" in renderMedia(), stitchFramesToVideo(), renderMediaOnLambda() or renderMediaOnVercel().Commonly a GIF has a lower frame rate than a video. For this, we support a parameter everyNthFrame that works as follows:
everyNthFrame is set to 1: Frames 0, 1, 2, 3, 4 and so on are rendered.everyNthFrame is 2, only every 2nd frame is rendered: 0, 2, 4, 6 and so on. A 30FPS video would now become a 15FPS GIF.everyNthFrame is 3, only every 3rd frame is rendered: 0, 3, 6, 9 and the pattern continues.The first frame is always included. When using a custom frameRange, everyNthFrame offsets from the start of the range.
everyNthFrame is supported:
renderFrames(), renderMedia(), renderMediaOnLambda() and renderMediaOnVercel()--every-nth-frame=2 locally or on Lambda.setEveryNthFrame().The numberOfGifLoops option allows you to set the number of loops as follows:
null (or omitting in the CLI) means to play the GIF indefinitely.0 disables looping.1 loops the GIF once (plays twice in total)2 loops the GIF twice (plays three times in total)The numberOfGifLoops option can be set:
--number-of-gif-loops=0 flag when rendering locally or on Lambda.stitchFramesToVideo(), renderMedia(), renderMediaOnLambda() and renderMediaOnVercel()setNumberOfGifLoops().Wondering how to import other GIFs into a Remotion project? See here.
To render a transparent GIF, the imageFormat option must be set to "png". In the Remotion Studio, this can be set in the "Picture" tab.