星期六, 9月 13, 2008

有關 Processing裡面 movie maker的測試 來自 網友PhiLho

Test of MovieMaker video type
« on: May 20th, 2008, 11:27pm »
Quote \ Modify

I tried to make a QuickTime video out of an animation I made, but it was late, so I lacked time. I tried a few codecs (types) at random, and either I got an awful quality, or enormous files! Or exceptions... 
So today I made a little sketch to test all the types, and I thought I could share, since a quick search on the (current) forum doesn't show such study. 
I made a non-trivial (ie. gradient), animated background, and some simple objects to see how they are animated and if they leave trails (traces) on the background. 
Here is the code, if you want to experiment at home: 
Code:
import processing.video.*; 
 
final int CANVAS_WIDTH  = 720; 
final int CANVAS_HEIGHT = 480; 
//~ final int MAX_FRAME_NB  = 720; 
final int MAX_FRAME_NB  = 120; 
 
final color START_COLOR_TOP    = #335533; 
final color START_COLOR_BOTTOM = #55AA55; 
final color END_COLOR_TOP = #333355; 
final color END_COLOR_BOTTOM   = #5555AA; 
 
int xA, yA, xB = CANVAS_WIDTH / 4, yB = CANVAS_HEIGHT / 4; 
 
MovieMaker mm; 
 
color InterpolateColor(color startC, color endC) 

  return lerpColor(startC, endC, (float)frameCount / (float)MAX_FRAME_NB); 

 
void DrawBackground() 

  color topColor = InterpolateColor(START_COLOR_TOP, END_COLOR_TOP); 
  color bottomColor = InterpolateColor(START_COLOR_BOTTOM, END_COLOR_BOTTOM); 
  for (int l = 0; l < CANVAS_HEIGHT; l++) 
  { 
    color sc = lerpColor(topColor, bottomColor, (float)l / (float)CANVAS_HEIGHT); 
    stroke(sc); 
    line(0, l, CANVAS_WIDTH - 1, l); 
  } 

 
void setup() 

  smooth(); 
  frameRate(24); 
  size(CANVAS_WIDTH, CANVAS_HEIGHT); 
 
  // I manually changed the name in the file and the type 
  mm = new MovieMaker(this, width, height, "Test-BASE.mov", 24, 
    MovieMaker.BASE, MovieMaker.BEST); 

 
void draw() 

  if (frameCount > MAX_FRAME_NB) 
  { 
    mm.finish(); 
    delay(1000); 
    exit(); 
  } 
 
  DrawBackground(); 
  fill(#88FFFF); 
  ellipse(xA++ * 4, yA++ * 4, 20, 20); 
  fill(#88AAFF); 
  ellipse(xB-- * 4, yB-- * 4, 20, 20); 
  fill(#88FFAA); 
  ellipse(xA * 4, yB * 4, 20, 20); 
  fill(#88AAAA); 
  ellipse(xB * 4, yA * 4, 20, 20); 
 
  fill(#8888AA); 
  ellipse(xA * 4 + MAX_FRAME_NB, yA * 4, 20, 20); 
  fill(#88AA88); 
  ellipse(xB * 4 - MAX_FRAME_NB, yB * 4, 20, 20); 
  fill(#8888AA); 
  ellipse(xA * 4 + MAX_FRAME_NB, yB * 4, 20, 20); 
  fill(#888888); 
  ellipse(xB * 4 - MAX_FRAME_NB, yA * 4, 20, 20); 
 
  mm.addFrame(); 


Tested with Apple QuickTime 7 for Windows (XP SP2) 
ANIMATION: perfect - 1,800KB 
BASE: empty! - 0 
BMP: perfect, enormous! - 121,500KB 
CINEPAK: Lot of artifacts on background, trail - 1,600KB 
COMPONENT: Little artifacts on background, big! - 81,000KB 
CMYK: empty! - 0 
GIF: empty! - 0 
GRAPHICS: Dithering - 16,600KB 
JPEG: Good quality, reasonable size - 2,500KB 
MS_VIDEO: empty! - 0 
MOTION_JPEG_A: Good quality, reasonable size - 3,200KB 
MOTION_JPEG_B: Good quality, reasonable size - 3,200KB 
RAW: perfect, enormous! - 162,000KB 
SORENSON: Little artifacts on background, small - 780KB 
VIDEO: Small palette (blocky gradient), trails - 470KB 
H261: Lot of artifacts on background - 460KB 
H263: Lot of artifacts on background - 330KB 
H264: Sketch fails (exception quicktime.std.StdQTException[QTJava:7.4.5g],-8960=codecErr,QT.vers:7458000) after writing 120KB 
 
Writing big files slows down a lot the animation... 
 
I hope this will help people.