Re: Generating a movie

From: Tom Roberts <tjrob_at_fnal.gov>
Date: Thu, 12 Mar 2009 15:51:47 -0500


Olivier Couet wrote:
> You can also generate an animated gif file like in the example:
> $ROOTSYS/tutorials/image/hsumanim.C

That works, but it slows down greatly for more than ~50 frames. It's not suitable for my needs.

Philippe Canal wrote:
> You can speed things up by disable the graphical display:
> root -b -q movie.C

Thanks! That more than doubles the speed.

Ultimately I will need a GUI for the user to specify the parameters of the movie. I could write the GUI in Java and then run Root for the conversion, or I could write the GUI in Root and then run a second instance of Root without graphics. Is there any way to do that without two Root instances? That is, in a Root session with a GUI, create a TCanvas disconnected from the graphics system, and then use it to create many (>1000) .png files.

Tom Roberts

>
> Cheers,
>
> Olivier
>
> -----Original Message-----
> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
> On Behalf Of Tom Roberts
> Sent: Thursday, March 12, 2009 5:07 PM
> To: 'ROOT Talk'
> Subject: [ROOT] Generating a movie
>
> 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 - 21:52:59 CET

This archive was generated by hypermail 2.2.0 : Thu Mar 12 2009 - 23:50:01 CET