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 & HelpPrograms › How to export a sketch to AVI
Page Index Toggle Pages: 1
How to export a sketch to AVI ? (Read 2745 times)
How to export a sketch to AVI ?
Nov 21st, 2008, 10:54pm
 
How do i export a sketch to avi raw or even better png's ?

And how to i tell Processing how long the video must be , like 60 frames for example.

There is another thing, i have my sketch running at 60, but i want my avi to run acctually at 25 fps.


thanx !
Re: How to export a sketch to AVI ?
Reply #1 - Nov 22nd, 2008, 6:04pm
 
SaveFrame will save the current display as a png

http://processing.org/reference/saveFrame_.html

as for stopping - just increment a counter in your draw loop and exit at the required number of frames.

your sketch won't run at 60fps if it's saving a png every frame.

as for forcing the final avi to 25fps, that's a function of whatever you're using to create the avi from the pngs rather than processing.

(i use mencoder in linux -
http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html - have used this with 15000 frames for a 10 minute animation)
Re: How to export a sketch to AVI ?
Reply #2 - Nov 22nd, 2008, 6:05pm
 
I used the QuickTime video library to export a movie. The code of the code is:
Code:
void setup()
{
smooth();
frameRate(24);

// Some init code here ...

if (bExportVideo)
{
mm = new MovieMaker(this, width, height, "movie.mov", 24,
MovieMaker.JPEG, MovieMaker.BEST);
}
}

void draw()
{
// Stop on the wanted frame number
if (frameCount > MAX_FRAME_NB)
{
if (bExportVideo)
{
mm.finish();
delay(1000);
}
exit();
}
DrawBackground();

// Some drawing code here ...

if (bExportVideo)
{
mm.addFrame();
}
}

Now, it won't export AVI, I think. I don't know if another library can do that.
You write exporting PNG can do the job, indeed you can post-process them with something like ffmpeg or similar.
You can use saveFrame() (or just save()) for this task.

Framerate: not an issue if you collect a bunch of PNGs, but as shown above, there is a function to control this.
Re: How to export a sketch to AVI ?
Reply #3 - Nov 23rd, 2008, 2:22pm
 
Thanx, i am very new, so i dont know where to put that code in my sketch,

Her's my sketch :
Code:

/*Bouncing ball
*/


//Declare global variables
int xspeed, yspeed;
int xpos,ypos,wdth,ht;

//inicializar sketch

void setup(){

//set sketch window and background color

size(800,300);
background(#FA005C);
smooth();

//ball speed

xspeed = 8;
yspeed = 9;


// ball size


wdth = 10;
ht = 10;

noStroke();

//initial ball placement

xpos = width /2;
ypos = height /2;

frameRate(60);
}

//begin animation draw

void draw (){

//update background

//lbackground (#FA005C);

// draw ball
ellipse ( xpos,ypos,wdth,ht);

//upgrade ball position

xpos+=xspeed;
ypos+=yspeed;

/*detects ball collition with sketch window edges also accounts for thickness of the ball
*/

if ( xpos>width-wdth/2 || xpos<=wdth/2){
xspeed*=-1;
}
if (ypos>=height-ht/2 || ypos<=ht/2){
yspeed*=-1;
}
}


Can you tell me where to put the code ?

Thanx !
Re: How to export a sketch to AVI ?
Reply #4 - Nov 23rd, 2008, 2:44pm
 
Look at linked saveFrame() reference: it is always called at the end of draw() routine.
Re: How to export a sketch to AVI ?
Reply #5 - Nov 23rd, 2008, 4:04pm
 
Thanx, i tried to put the code at the end of my void draw, but i get this error, i puted the new code where its yellow.
Hope you can help me , thanx!

http://www.mediafire.com/imgbnc.php/ee7b414f24a9ae9bd6f276bfa03f6bac6g.jpg
Re: How to export a sketch to AVI ?
Reply #6 - Nov 23rd, 2008, 6:39pm
 
Well, the code with x is unrelated, it is the animation example of the sample code. Just add saveFrame(). And you can use a .png extension there.
Re: How to export a sketch to AVI ?
Reply #7 - Nov 23rd, 2008, 9:58pm
 
Allright ! I got it , thanx !!!
Page Index Toggle Pages: 1