Record a video with Pen tools

//--loop
w.draw{

	world.objects.do{|o, i|
		var prev= world.objects.wrapAt(i-1);
		var next= world.objects.wrapAt(i+1);
		o.calculateCoupling(prev, next);
	};

	world.objects.do{|o|
		var c, d, r;

		o.update(~speed);

		o.loc[0]= (o.theta1.cos+o.theta2.cos)*~scale/4+0.5*width;
		o.loc[1]= (o.theta1.sin+o.theta2.sin)*~scale/4+0.5*height;
			// o.loc[0].linlin(0, 500, -1, 1).postln; //xpos_normalize
			// o.loc[1].linlin(0, 500, 1, -1).postln; //ypos_normalize

		c= (o.totalSpeed+0.25).min(1);
		d= 1+o.speedDifference;

		//--render
		r= Rect.aboutRedObject2D(o);
		r.width= r.width*d;
		r.height= r.height*d;
		Pen.fillColor= Color.grey(((o.theta1+o.theta2).abs*5+0.25).min(0.3));
			//Pen.fillColor= Color.grey(c);
		Pen.fillOval(r);
		//o.theta1%2.postln;

		};

		world.objects.do{|o, i|
			var f1,f2 ;
			f1 = o.theta1%(2*pi);
			f2 = o.theta2%(2*pi);
			//o.totalSpeed.postln;

			synths[i].set(  //f0 changed synth.[i] to synths[i]
				//{f1+f2}.plot;  //f0 not good to plot here. it will overload
				\theta1, f1,  //f0 changed from ; to ,
				\theta2, f2,  //f0 changed from ; to ,
				\t_trig, 1,
				\amp, 1,
				\freq1, (f1)*100,
				//\freq2, (f2)*60,
			);
		};

};

Here is the part of my code, a simulation for the idea of concept,
It will not run directly. It has some other variables and dependencies,
Does it have a method to record the video inside the Sc? or should I just use it as a capture tool?

w= RedWindow("janus bunch", Rect(128, 64, width, height)).front;
w.background = Color.white;
world= RedWorld3(RedVector2D[width, height], nil, inf, 0);	//dim,grav,maxvel,damp

windows open as a separate window

I have used a capture tool in the past, which is easy. But if you really want to do this from inside SC you could possibly use

Image.fromWindow

30 times per second, save them as image files and string them together into a movie file using e.g. ffmpeg

(I haven’t tried this so not sure how practical it is)