We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpVideo Capture,  Movie Playback,  Vision Libraries › Why the movie is faster and quality is not good
Page Index Toggle Pages: 1
Why the movie is faster and quality is not good? (Read 1462 times)
Why the movie is faster and quality is not good?
Jun 9th, 2010, 6:47pm
 
I'm trying minim library and when I try to record the sketch with moviemaker, the result came out not as I expected. Although, it seems perfect fine while running the real-time simulation, the ".mov" is so different with the real-time one. When the bubbles fade away, it came out awkard mozaics. I don't know why this is happening. What's more, the ".mov" 's speed seems a lot faster than the real-time one, Where would I adjust these setting? At last, can I record the video with sound also, how can I get video and sound at the same time?

P.S.: in order to work, you must have one song in the folder of the sketch file. I didn't upload the mp3 file.


Code:
import processing.video.*;
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.*;


Minim minim;
AudioPlayer song;
FFT fft;
ArrayList trails;
MovieMaker mm;

void setup()
{
 size(1024, 800);
 smooth();
 frameRate(128);
 mm = new MovieMaker(this, width,height,"bubbles.mov",30,MovieMaker.VIDEO, MovieMaker.LOSSLESS);
 // always start Minim first!
 minim = new Minim(this);

 // specify 1024 for the length of the sample buffers
 // the default buffer size is 1024
 song = minim.loadFile("糖不厌.mp3", 1024);
 song.play();

 // an FFT needs to know how
 // long the audio buffers it will be analyzing are
 // and also needs to know
 // the sample rate of the audio it is analyzing
 fft = new FFT(song.bufferSize(), song.sampleRate());

 trails = new ArrayList();

}

void draw()
{
 background(0);
 //spectrum
 // first perform a forward fft on one of song's buffers
 // I'm using the mix buffer
 //  but you can use any one you like
 fft.forward(song.mix);

 //stroke(255, 0, 0, 128);
 //strokeWeight(5);
 // draw the spectrum as a series of vertical lines
 // I multiple the value of getBand by 4
 // so that we can see the lines better
 for(int i = 0; i < (fft.specSize()-1)*2; i+=1024/(fft.specSize()-1))
 {
   //line(i, height, i, height - fft.getBand(i)*5);

   if(dist(i,height, i, height - fft.getBand(i)*5)>height/20){
Circle c = new Circle(int(random(0,width)), int(random(0,height)), random(10,50), random(0,255));
c.drawOneCircle();
   }
 }

 //trails
 for(int j = 0; j < trails.size(); j++){
   Trail t = (Trail) trails.get(j);
   t.update();
   t.drawOneCircle();
 }


 //waveform
 stroke(255);
 strokeWeight(0);
 // we draw the waveform by connecting neighbor values with a line
 // we multiply each of the values by 50
 // because the values in the buffers are normalized
 // this means that they have values between -1 and 1.
 // If we don't scale them up our waveform
 // will look more or less like a straight line.
 for(int i = 0; i < song.bufferSize() - 1; i++)
 {
   //    line(i, height/2 - 50 + song.left.get(i)*50, i+1, height/2 - 50 + song.left.get(i+1)*50);
   //    line(i, height/2 + 50 + song.right.get(i)*50, i+1, height/2 + 50 + song.right.get(i+1)*50);
   //    line(i, height/2 + song.mix.get(i)*50, i +1, height/2 + song.mix.get(i+1)*50);
 }

 mm.addFrame();


}

void stop()
{
 song.close();
 minim.stop();

 super.stop();
}

void keyPressed(){
 if(key == 'f'){
   mm.finish();
   println("movie saved");  
 }

 if ( key == 'p' ) song.play();

}

class Trail{
 //variable
 int posx;
 int posy;
 float radius;
 float magnatude;

 //constructor
 Trail(int _posx, int _posy, float _radius, float _magnatude){
   posx = _posx;
   posy = _posy;
   radius = _radius;
   magnatude = 255;
 }

 //method
 void update(){
   magnatude-=30;

   if(magnatude < 0){
trails.remove(this);
   }
 }

 void drawOneCircle(){

   noStroke();
   fill(magnatude,magnatude,magnatude,10);
   ellipse(posx,posy,radius*4,radius*4);
   fill(magnatude,magnatude,magnatude,10);
   ellipse(posx,posy,radius*3,radius*3);
   fill(magnatude,magnatude,magnatude,10);
   ellipse(posx,posy,radius*2.5,radius*2.5);

   //stroke(0,60);
   fill(magnatude);
   ellipse(posx,posy,radius*2,radius*2);

   //color
//    noStroke();
//    for(int k = 1; k < 30; k++){
// fill(random(0,magnatude),random(0,magnatude),random(0,magnatude),20);
// arc(posx, posy, radius*2, radius*2, random(0,2*PI), random(0,2*PI));
//    }


//    for(float i = 0.0; i < 2.0*PI; i+=0.5-radius/200){
// stroke(0,random(0,100));
// line(posx,posy,posx+sin(i)*radius,posy+cos(i)*radius);
//    }

 }


}

class Circle{
 //variable
 int posx;
 int posy;
 float radius;
 float magnatude;

 //constructor
 Circle(int _posx, int _posy, float _radius, float _magnatude){
   posx = _posx;
   posy = _posy;
   radius = _radius;
   magnatude = _magnatude;
 }

 //method
 void drawOneCircle(){

   noStroke();
   fill(magnatude,magnatude,magnatude,10);
   ellipse(posx,posy,radius*4,radius*4);
   fill(magnatude,magnatude,magnatude,10);
   ellipse(posx,posy,radius*3,radius*3);
   fill(magnatude,magnatude,magnatude,10);
   ellipse(posx,posy,radius*2.5,radius*2.5);

   //stroke(0,60);
   fill(255);
   ellipse(posx,posy,radius*2,radius*2);

   //color
   noStroke();
   for(int k = 1; k < 30; k++){
fill(random(0,magnatude),random(0,magnatude),random(0,magnatude),20);
arc(posx, posy, radius*2, radius*2, random(0,2*PI), random(0,2*PI));
   }


//    for(float i = 0.0; i < 2.0*PI; i+=0.5-radius/200){
// stroke(0,random(0,100));
// line(posx,posy,posx+sin(i)*radius,posy+cos(i)*radius);
//    }

   trails.add(new Trail(posx, posy, radius, magnatude));

 }


}












Re: Why the movie is faster and quality is not good?
Reply #1 - Jun 10th, 2010, 12:57am
 
Just a hunch, but I'd imagine there's a price to pay in terms of processing overhead when running MovieMaker.  That could be slowing down your sketch in 'live view' (remember that frameRate is something Processing aims to run at and isn't guaranteed), but if MM just renders out each frame and incorporates it into a video then I imagine it could well play back faster...  In fact at the 'intended' speed.

If seamlessly exporting video is the intention of the sketch then I'm not sure what to suggest; however if you just want to export a one-off video of it running - perhaps to post on a blog - you'll probably find it much easier to use some screen capture software (Camtasia is a well known example, but I'm sure there are plenty of alternatives).
Page Index Toggle Pages: 1