how to set framerate of gif (gifAnimation lib)?

edited December 2017 in Library Questions

the exported gif always running at 10 fps. how to make higher fps;
gifAnimation 3.0.0 _ processing 3.3.4

    import gifAnimation.*;      
    GifMaker gifExport;
    float x;

    void setup() {
      size(200, 200);     
      gifExport = new GifMaker(this, "export.gif");
      gifExport.setRepeat(0); 
    //setDelay()  can make gif slower ,but can't make gif run faster ,   
      gifExport.setDelay(0);             
    }        
    void draw() {
      x=x+3;
      fill(250);
      ellipse(x,10,30,30);  
      gifExport.addFrame();  
    }

    void keyPressed() {
      gifExport.finish();
    }

Answers

  • edited August 2017

    See void setDelay(int ms) here: http://extrapixel.github.io/gif-animation/

    Sets the delay (the "framerate") for the most recently added frame. This is measured in Milliseconds. This can be different for every frame. Note, this effects the playback speed of the resulting GIF-file only. So, the speed / framerate with which you wrote the frames has no effect on play- back speed.

  • edited August 2017

    Thank you ,But how to control the framerate of exported GIF, I've already set 0 delay ,But it still has 100ms delay ,During GIF playback.

  • Interesting -- that contradicts the documentation here:

    https://github.com/01010101/GifAnimation#void-setdelayint-ms

    void setDelay(int ms)

    Sets the delay (the "framerate") for the most recently added frame. This is measured in Milliseconds. This can be different for every frame. Note, this effects the playback speed of the resulting GIF-file only. So, the speed / framerate with which you wrote the frames has no effect on play- back speed.

    Have you tried low non-zero numbers? If they don't work, it might be worth filing an issue on github.

  • Answer ✓

    https://github.com/extrapixel/gif-animation/blob/3.0/gifAnimation/src/GifEncoder.java#L208

    You'll want to use the following in setup() where you replace 60 with your frame rate:

    gifExport.setDelay(1000/60);

Sign In or Register to comment.