Animated GIF

Greetings Rooter’s

I am attempting to write out an animated gif from an array of Histograms.
Problem is, the larger the histogram array the slower the production.

This might seem confusing so here is my example.

When If I were to use only the indexes
ds <1, s<1, wj <1, mom<18 (see code below) the amount of time to make this .gif is about 10 seconds

 TString PID[3]={"P_","Pip_","Pim_"};
   
   TCanvas *c1 = new TCanvas("c1","Histo",800,650);
   c1->Divide(2,1);
   for(int ds=0; ds<1; ds++){//9
      Int_t ID = (0+ds)/3;
      char giffer[50];
      sprintf(giffer,"%s%s%s%s","/Volumes/Mac_Storage/YIELD/SINGLE_TRACK/YIELD_DATA/PRODUCTION/RUN_56515/FITKIN_Plots/Histogram_",PID[ID].Data(),PULL[ds].Data(),".gif+200"); 
      for(int s=0;s<1;s++){ //6
         for(int wj=0;wj<1;wj++){//15
            for (int mom =0; mom <18; mom++) {//18
               
               c1->cd(1);
               TF1 *g1 = new TF1("g1","gaus",pt_lo,pt_up); 
               Hist_[ds][s][wj][mom]->Draw();//Fit(g1,"R,Q");
               c1->cd(2);
               Histcor_[ds][s][wj][mom]->Draw();//Fit(g1,"R,Q");
               
               char axis[50];
               sprintf(axis,"%s%s%s",PID[ID].Data(),"  ",PULL[ds].Data()); 
               Hist_[ds][s][wj][mom]->GetXaxis()->SetTitle(axis);
               Histcor_[ds][s][wj][mom]->GetXaxis()->SetTitle(axis);
               c1->Print(giffer);   
               
               
            }//------Close Momenta
         }//----------- Close Theta
      }//-----------Close Sector

Now if I were to use:
ds <9, s<6, wj <15, mom<18 (same code see below) You would expect this to take approximately 2 hours.
However I ran this for 10 hours and only was able to produce an animated gif to the variables
ds =2, s=1, wj =12, mom=12

[code] TString PID[3]={“P_”,“Pip_”,“Pim_”};

TCanvas *c1 = new TCanvas(“c1”,“Histo”,800,650);
c1->Divide(2,1);
for(int ds=0; ds<9; ds++){//9
Int_t ID = (0+ds)/3;
char giffer[50];
sprintf(giffer,"%s%s%s%s","/Volumes/Mac_Storage/YIELD/SINGLE_TRACK/YIELD_DATA/PRODUCTION/RUN_56515/FITKIN_Plots/Histogram_",PID[ID].Data(),PULL[ds].Data(),".gif+200");
for(int s=0;s<6;s++){ //6
for(int wj=0;wj<15;wj++){//15
for (int mom =0; mom <18; mom++) {//18

           c1->cd(1);
           TF1 *g1 = new TF1("g1","gaus",pt_lo,pt_up); 
           Hist_[ds][s][wj][mom]->Draw();//Fit(g1,"R,Q");
           c1->cd(2);
           Histcor_[ds][s][wj][mom]->Draw();//Fit(g1,"R,Q");
           
           char axis[50];
           sprintf(axis,"%s%s%s",PID[ID].Data(),"  ",PULL[ds].Data()); 
           Hist_[ds][s][wj][mom]->GetXaxis()->SetTitle(axis);
           Histcor_[ds][s][wj][mom]->GetXaxis()->SetTitle(axis);
           c1->Print(giffer);   
           
           
        }//------Close Momenta
     }//----------- Close Theta
  }//-----------Close Sector

[/code]

Why does it take mush longer, and can I do something different to shorten the time?

Thanks
Michael

I guess that, when an animated gif is produced, the time gets longer and longer because somehow the new gif need to be append to a longer and longer file which has to be scanned.
That is just a guess.

Can you provide a small macro we can run reproducing this behavior ? (the one you sent look very dependent on your local file structure).

An other suggestion would be to generate simple gif files and concatenate them in a animated gif with some external tool …

But first lets try to reproduce the behavior you see.

I appreciate the help.
I have attached a small code and a very small data file.
I know that there will be many empty pads due to the size of the file being proportional to the amount of data, however just trying to create an animated gif with empty pads will produce the discrepancy.

As the code is written now, the gif will not be done with creation for 12+ hours.

If one were to change the gif creation portion to

for(int wj=0;wj<1;wj++){ //-----------Momenta 18 for (int mom =0; mom<1; mom++) { //--------------Z 10 for (int cd =0; cd<24; cd++) { //--------------Phi

Each animated gif will be produced in about 45 secs.
small.root (1.64 MB)
smallHistoArrayII.C (9.01 KB)

Please add line

to branch addressing section.

I see. I also see the same thing with some other examples I have.
After 100 pictures it becomes really slow.
I think you are not using the write tool… what do you want to achieve exactly ?
make a movie ?

Yes, I am trying to make a movie using all the indices In the macro.

So an animated gif produced this way is surely not the best approach.
I would suggest you generate the individual pictures and then you use an external tool to combine them.

[quote=“couet”]
I would suggest you generate the individual pictures and then you use an external tool to combine them.[/quote]

This approach was my first attempt and it also failed, for the same reasons.

To be more specific, I have tried the following methods.

Use ROOT to generate individual histograms
Use GIFFun, Mathematica, other GIF producing tools to produce sequential movie.
result: time out

Use ROOT to generate partial animation
Use GIFFun, Mathematica, other GIF producing tools to produce rest of sequential movie.
result: timeout

Use ROOT to generate whole movie
result: timeout

So I am going to interpret your reply as “Can’t be done”

If you google a bit I guess you can find some help. Like this:

superuser.com/questions/249101/h … apse-movie

I have tried this as well, with no success

Ok, so you know more than me.

??

I mean I have no more hint to give you. You have tried all the hints I gave you including the latest I found on google. None of them work for you. I am sure sure you even found some I have not seen yet. That’s why I think you know more than me on this topic and therefore I am not great help.

May be IMovie on Mac can do something … let me see.

Does not seem to be the right tool …

I found a solution. I did what is recommended here:
stackoverflow.com/questions/6184 … into-video

I have generated 10000 png files and with ffmpeg I was able to glue them very quickly.
I use the command:

ffmpeg -qscale 5 -r 20 -b 9600 -i h%05d.png movie.mp4

my files are h00001.png to h09999.png

the original page is :
miscdebris.net/blog/2008/04/ … png-jpegs/

(mentioned in the previous URL I sent)

Thank you,

Unfortunately, it appears there is no build for Mac OSX 10.7.2 (Lion).

I have contacted their developers.

Again Thanks

Michael

No need to have a build. I am working on Lion too. Take the SVN distribution and install it yourself.
It is straight forward ! I managed to do it… so every body can do it :slight_smile:

From GIT or their SVN?

I ask because when I get the SVN and configure, I get errors about yasm.

edit:same problem using GIT.
I am unsure how you installed this without LAME and it appeared LAME was not yet Lion compatible.