Generating a movie

From: Tom Roberts <tjrob_at_fnal.gov>
Date: Thu, 12 Mar 2009 11:06:52 -0500


I want to generate a movie of the data contained in a TNtuple.

   The TNtuple rows each contain one sample of a track:

        t,x,y,z,Px,Py,Pz,trackID,particleID.
   There are ~100 tracks in the TNtuple, ~100,000 total rows.    The beam center is along the z axis.

My current plan is to generate successive frames using an x-y plot of the TNtuple with a cut on t, do canvas->SaveAs("movie_%d.png") [%d = frame number], then increment the cut on t and the frame number, repeating until the TNtuple has no remaining entries. I'll increment t corresponding to the movie's frame rate, interpolating the TNtuple data (ensuring that each existing track has exactly 1 entry).

	[I have more sophisticated plans; this is the simplest to
	 describe and covers the essential issues.]

That generates hundreds to thousands of .png files. I then use ffmpeg to convert them to a movie (this is a remarkable, open-source tool). http://www.ffmpeg.org/

The attached macro generates 500 frames of a 21-second movie using test data (25 trajectories each moving in a randomized circle):

	root movie.C
	--- took 73 sec
	ffmpeg -r 24 -i m_%d.png m.mov
	--- took 6 sec

Commenting out the SaveAs(), the macro executes in 4 sec, essentially all of which is overhead, so there's not much point in optimizing or compiling it.

This is not bad, creating the movie at a rate of 1/4 real time. But I am new to making movies and wonder if I'm missing something obvious. So I ask:

Is there a better way to do this?
Are there better tools available?
Is there any way to speed up the SaveAs()? The canvas was clearly visible and updated at each frame; can that be avoided to speed it up?
Which image format is best? (ffmpeg supports most) Which movie format is best? (ffmpeg supports most)

BTW I salute the entire Root team for making such a flexible program! It's amazing that I could start from just a vague notion and create such a test movie in about 1/2 day (half of which was finding ffmpeg).

Tom Roberts

Received on Thu Mar 12 2009 - 17:20:20 CET

This archive was generated by hypermail 2.2.0 : Fri Mar 13 2009 - 17:50:01 CET