HA: Generating a movie

From: Valeri Onuchin <Valeri.Onoutchine_at_cern.ch>
Date: Fri, 13 Mar 2009 11:15:56 +0100


Hi,
>Is there a better way to do this?

you already found it - ffmpeg converting bunch of images into MPEG4 format which is "state of the art" for todays

>Are there better tools available?

there are a lot of tools which can produce "movie" from bunch of images. The choice what is desired output format. Probably ffmpeg on of the best one around (btw, they just released recently http://www.ffmpeg.org/)

>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?

As far as I understtod you are idea is redrawing only "dirty regions" or XORing successive frames and redrawing only changing parts.  

IMO, will require a lot of "re-working" in "raster mode", but it's built-in in hardware with GL. So, rewriting pad graphics with GL will give (by my estimate) an order of speed up.

>Which image format is best? (ffmpeg supports most)

it depends on quality of movie which you would like to have. I would recommend old good GIFs.

>Which movie format is best? (ffmpeg supports most)

as I mentioned MPEG4 (H.264 codec http://ru.wikipedia.org/wiki/H.264) ... or MPEG-7 :) if you'll find a tool

Regards. Valeriy

-----Исходное сообщение-----
От: owner-roottalk_at_root.cern.ch от имени Tom Roberts Отправлено: Чт, 3/12/2009 5:06
Кому: 'ROOT Talk'
Тема: [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 Fri Mar 13 2009 - 11:16:06 CET

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