Hey everyone,
I'd like to kick off a discussion (once more) on saving your sketch's output.
How to record a sketch's output to a movie or image sequence has long been a topic of discussion and somewhat of a weak spot of Processing. I just downloaded Processing 2.0a3 and I see that it includes a MovieMaker tool to create a Quicktime movie from a sequence of images. A useful addition in itself, but also one that in my opinion circumvents the real issue. In the accompanying text, the saveFrame function and the tif file format are suggested to create an image sequence.
So I thought I would do some frameRate tests at the resolution I usually work in: 1920 x 1080. See the results below. Some comments that I take away from it. Both from this simple test, but also my experiences in general.
Test Code
Test Results
I'd like to kick off a discussion (once more) on saving your sketch's output.
How to record a sketch's output to a movie or image sequence has long been a topic of discussion and somewhat of a weak spot of Processing. I just downloaded Processing 2.0a3 and I see that it includes a MovieMaker tool to create a Quicktime movie from a sequence of images. A useful addition in itself, but also one that in my opinion circumvents the real issue. In the accompanying text, the saveFrame function and the tif file format are suggested to create an image sequence.
So I thought I would do some frameRate tests at the resolution I usually work in: 1920 x 1080. See the results below. Some comments that I take away from it. Both from this simple test, but also my experiences in general.
- The sketch runs substantially faster in OPENGL, in this case 10x faster.
- P2D is in many areas faster than JAVA2D (but is no longer included from 2.0 onwards).
- saveFrame in combination with tif or png is in no version of Processing and in no renderer a viable option as it completely kills the frameRate, decreasing it in some cases to less than 1% of the original speed.
- saveFrame in combination with tga is/was a relatively good option to combine regular resolutions with a decent frameRate when saving frames. See the saveFrame cases for JAVA2D and P2D. Unfortunately for OPENGL and GLGraphics even tga can be considered a frameRate killer, given the drop in frameRate.
- The java-based open source GNU-GPL (hint!) program Krut and the JAVA2D / P2D cases show that the problem is NOT the speed of the hard drive. It is possible to capture at this resolution in realtime. The problem (and hopefully the solution) lies in the code.
- As Processing gets faster (also through the integration of GLGraphics) and more users start working at HD resolutions, the need only grows to be able to reliably capture the output from these sketches in realtime. A tool that somehow captures a movie or even an image sequence at decent frameRates would be a great (and long missed) addition to Processing.
Test Code
- import processing.opengl.*;
- // import codeanticode.glgraphics.*;
- void setup() {
- size(1920, 1080, OPENGL);
- // size(1920, 1080);
- // size(1920, 1080, GLConstants.GLGRAPHICS);
- frameRate(2000);
- textSize(100);
- background(0);
- noStroke();
- }
- void draw() {
- fill(random(255), random(255), random(255));
- ellipse(random(width), random(height), 100, 100);
- fill(0);
- rect(0, 0, 450, 150);
- fill(255);
- text(int(frameRate) + " fps", 0, 100);
- // saveFrame("frames/####.tif");
- }
Test Results
- // Processing 1.5.1
- // size(1920, 1080); => 40 fps
- // saveFrame("frames/####.tif"); => 3 fps
- // saveFrame("frames/####.png"); => 3 fps
- // saveFrame("frames/####.tga"); => 30 fps
- // size(1920, 1080, P2D); => 100 fps
- // saveFrame("frames/####.tif"); => 3 fps
- // saveFrame("frames/####.png"); => 3 fps
- // saveFrame("frames/####.tga"); => 60 fps
- // size(1920, 1080, OPENGL); => 350 fps
- // OPENGL + saveFrame("frames/####.tif"); => 3 fps
- // OPENGL + saveFrame("frames/####.png"); => 3 fps
- // OPENGL + saveFrame("frames/####.tga"); => 20 fps
- // size(1920, 1080, GLConstants.GLGRAPHICS); => 435 fps
- // GLGRAPHICS + saveFrame("frames/####.tif"); => 3 fps
- // GLGRAPHICS + saveFrame("frames/####.png"); => 3 fps
- // GLGRAPHICS + saveFrame("frames/####.tga"); => 25 fps
- // Processing 2.0a3
- // size(1920, 1080); => 40 fps
- // saveFrame("frames/####.tif"); => 3 fps
- // saveFrame("frames/####.png"); => 3 fps
- // saveFrame("frames/####.tga"); => 26 fps
- // size(1920, 1080, OPENGL); => 410 fps
- // OPENGL + saveFrame("frames/####.tif"); => 3 fps
- // OPENGL + saveFrame("frames/####.png"); => 3 fps
- // OPENGL + saveFrame("frames/####.tga"); => 20 fps