Rendering a long animation to file, not real time

Hello @MichaelMean ,

Ignore below if you want to tackle this yourself.
Your post inspired me and I cooked this up this morning!

Related:
Movie Maker: Time gap between movie and its audio file - #2 by glv

This is a version of above that does rendering outside of draw():

/**
 * MovieMaker Frame Generator for Testing
 * 
 * Author:  glv
 * Date:    2025-07-23
 * Version: 1 0 0
 *
 * Generates frames for testing without draw():
 */

int marker_10s;

void setup()
  {
  //size(1920, 1080);
  size(600, 600); 
    
  int t0 = millis();
  
  int videoTimeSecs = 60;      // Must be in seconds 
  int desiredFrameRate = 60;   // For MovieMaker!
  int framesToSave = videoTimeSecs*desiredFrameRate;
  
  // frameRate(1000);             // Make this 1000 and let the rendering fly!  
  
  marker_10s = 10*desiredFrameRate;
  println("marker_10s:", marker_10s);
  println();
  println("It's show time!");
  println();
  println("videoTimeSecs:", videoTimeSecs);
  println("desiredFrameRate", desiredFrameRate);
  println("framesToSave", framesToSave );
  delay(1000);
  println();
  
  // Common to all text:
  textAlign(CENTER, CENTER);
  textSize(96);
  fill(0);
 
// If using drawFrame()
  for (int i = 0; i < framesToSave ; i++) 
    {
    drawFrame(i);
    //println(i);  // Fills console!

    if (i%100 == 0)  // Every 100!
      println(i);    
    
    saveFrame("frames/frame-" + nf(i, 5) + ".tga"); //tga is fast! png is slow...
    //saveFrame("frames/frame-" + nf(i, 5) + ".png"); //tga is fast! png is slow...
    }
  
   background(255, 255, 0); 
   text("Done!", width/2, height/2);  // Adjusted so starts at 0
  
  int t1 = millis();
  int dt = t1-t0;
  println("Total time:", nfs(dt/1000.0, 0, 2) + "s");
  println("Average frame:", nfs( (float) dt/framesToSave, 0, 2) + "ms");  
    
  //exit(); // Automatically close Processing window
  noLoop();
  }
  
void drawFrame(int frame)  
  {
  if(frame > marker_10s)
    {
    background(255, 0, 0);
    }  
  else
    background(255, 255, 0);
    
  text(frame, width/2, height/2);  // Adjusted so starts at 0
  }

It may need finessing.

:)

1 Like