Skip to content

@remotion/renderer: Fix numberOfGifLoops being ignored on Lambda#6547

Merged
JonnyBurger merged 2 commits intomainfrom
fix/gif-loops-lambda
Feb 17, 2026
Merged

@remotion/renderer: Fix numberOfGifLoops being ignored on Lambda#6547
JonnyBurger merged 2 commits intomainfrom
fix/gif-loops-lambda

Conversation

@JonnyBurger
Copy link
Member

Summary

  • numberOfGifLoops was not being forwarded to the muxVideoAndAudio step in combine-chunks.ts
  • When Lambda combines video chunks, combineVideoStreams correctly applies the -loop flag, but then muxVideoAndAudio re-muxes with -c:v copy without the -loop flag, causing FFmpeg's GIF muxer to default to infinite loop
  • Added numberOfGifLoops parameter to muxVideoAndAudio() so the -loop flag is preserved in the final output

Test plan

  • Verified bug: Lambda render with --number-of-gif-loops=0 produced infinite-loop GIF
  • Verified fix: Lambda render with --number-of-gif-loops=0 now produces play-once GIF
  • Verified fix: Lambda render with --number-of-gif-loops=3 produces 3-loop GIF
  • Verified fix: Lambda render with default (no flag) still produces infinite-loop GIF
  • Verified: Local render behavior unchanged

Closes #6512

🤖 Generated with Claude Code

The muxVideoAndAudio step was re-muxing the GIF with -c:v copy without
passing the -loop flag, causing FFmpeg's GIF muxer to use its default
(infinite loop) and overriding the correct loop count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 17, 2026 11:52
@vercel
Copy link
Contributor

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment Feb 17, 2026 0:51am
remotion Error Error Feb 17, 2026 0:51am

Request Review

@JonnyBurger JonnyBurger changed the title @remotion/renderer: Fix numberOfGifLoops being ignored on Lambda @remotion/renderer: Fix numberOfGifLoops being ignored on Lambda Feb 17, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes numberOfGifLoops being lost during Lambda chunk combination by preserving the GIF muxer -loop setting through the final muxVideoAndAudio step.

Changes:

  • Add numberOfGifLoops support to muxVideoAndAudio() and pass it through from internalCombineChunks().
  • Ensure FFmpeg -loop flag is applied during the final remux, not only during video stream combination.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/renderer/src/mux-video-and-audio.ts Adds numberOfGifLoops parameter and forwards it to FFmpeg as -loop.
packages/renderer/src/combine-chunks.ts Forwards numberOfGifLoops into the muxing step when combining chunks.

Comment on lines +50 to +53
numberOfGifLoops === null ? null : '-loop',
numberOfGifLoops === null
? null
: convertNumberOfGifLoopsToFfmpegSyntax(numberOfGifLoops),
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-loop is a GIF muxer option; adding it here whenever numberOfGifLoops !== null will make ffmpeg fail for non-GIF outputs if a caller passes numberOfGifLoops with e.g. codec: 'h264' (combineChunks is a public API and currently doesn’t validate this option). Consider gating these arguments to only be added when the output format is GIF (e.g. based on output extension / a passed-in codec, or by only passing non-null numberOfGifLoops from the caller when codec === 'gif').

Copilot uses AI. Check for mistakes.
cancelSignal,
addFaststart: codecSupportsFastStart[codec],
metadata,
numberOfGifLoops,
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numberOfGifLoops is forwarded to muxVideoAndAudio() unconditionally. Since combineChunks() is an exported API and does not currently validate numberOfGifLoops against codec, passing a non-null loop count for non-GIF codecs can now cause the mux step to fail (because muxVideoAndAudio will include -loop). Safer would be to pass codec === 'gif' ? numberOfGifLoops : null (or validate and throw a clearer error earlier).

Suggested change
numberOfGifLoops,
numberOfGifLoops: codec === 'gif' ? numberOfGifLoops : null,

Copilot uses AI. Check for mistakes.
…ot GIF

Also fix copy-paste error in validation message that said "everyNthFrame" instead of "numberOfGifLoops".

Co-authored-by: Cursor <cursoragent@cursor.com>
@JonnyBurger JonnyBurger merged commit 72276fc into main Feb 17, 2026
13 of 14 checks passed
@JonnyBurger JonnyBurger deleted the fix/gif-loops-lambda branch February 17, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@remotion/lambda: Number of GIF loops is not considered on Lambda

1 participant

Comments