Skip to content

@remotion/renderer: Improved render time estimates #5463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 26, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 24, 2025

The renderEstimatedTime calculation in render-media.ts was inaccurate because it used all frame timings to calculate the average render time, causing the first few slow frames to skew the estimation for the entire render.

Problem

The current algorithm:

  1. Accumulates time for ALL frames rendered so far in totalTimeSpentOnFrames
  2. Calculates average as totalTimeSpentOnFrames / renderedFrames
  3. Uses this average to estimate remaining time

This approach is problematic because:

  • Initial frames are often slower due to cold start, initialization, etc.
  • These slow frames continue to impact the average throughout the entire render
  • Time estimates remain pessimistic even as rendering speed stabilizes

Solution

Modified the algorithm to track only the most recent 50 frame timings:

// Track recent frame timings (at most 50)
recentFrameTimings.push(timeToRenderInMilliseconds);
if (recentFrameTimings.length > MAX_RECENT_FRAME_TIMINGS) {
    recentFrameTimings.shift();
}

// Calculate average using only recent timings for better estimation
const recentTimingsSum = recentFrameTimings.reduce((sum, time) => sum + time, 0);
const newAverage = recentTimingsSum / recentFrameTimings.length;

Benefits

  • More accurate time estimates that adapt to current rendering performance
  • Eliminates bias from slow initial frames
  • Provides better user experience with realistic progress indicators
  • Maintains backward compatibility (existing totalTimeSpentOnFrames preserved)

Changes

  • Added MAX_RECENT_FRAME_TIMINGS = 50 constant
  • Added recentFrameTimings: number[] array to track recent frame render times
  • Updated estimation calculation to use rolling average of recent timings
  • All existing tests pass

Fixes #5462.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link

vercel bot commented Jun 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bugs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 9:40am
remotion ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 9:40am

@Copilot Copilot AI changed the title [WIP] Better renderEstimatedTime calculation Improve renderEstimatedTime calculation using recent frame timings Jun 24, 2025
@Copilot Copilot AI requested a review from JonnyBurger June 24, 2025 09:09
Copilot finished work on behalf of JonnyBurger June 24, 2025 09:09
@JonnyBurger JonnyBurger marked this pull request as ready for review June 24, 2025 09:18
@JonnyBurger JonnyBurger enabled auto-merge June 24, 2025 09:19
@JonnyBurger JonnyBurger changed the title Improve renderEstimatedTime calculation using recent frame timings @remotion/renderer: Improved render time estimate Jun 24, 2025
@JonnyBurger JonnyBurger changed the title @remotion/renderer: Improved render time estimate @remotion/renderer: Improved render time estimates Jun 24, 2025
@JonnyBurger JonnyBurger disabled auto-merge June 24, 2025 09:28
@JonnyBurger JonnyBurger merged commit abe5838 into main Jun 26, 2025
14 checks passed
@JonnyBurger JonnyBurger deleted the copilot/fix-5462 branch June 26, 2025 10:07
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.

Better renderEstimatedTime calculation
2 participants