ofxGifEncoder throws no errors, but also won't create GIF

I’m trying to use ofxGifEncoder to generate short GIF animations, and I thought that I had everything set up correctly as per the given example (and a couple other examples I found on the web), but I’m not getting any GIFs in my data folder.

I’m uploading my ofApp.h and ofApp.cpp for faster reference, but maybe I can explain some of what I’ve got going on.

ofApp.h (877 Bytes)
ofApp.cpp (5.3 KB)

First I set up my encoder in my setup() function like so:

gifEncoder.setup(ofGetWidth(), ofGetHeight(), .25, 8);
ofAddListener(ofxGifEncoder::OFX_GIF_SAVE_FINISHED, this, &ofApp::onGifSaved);

fboImage.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR);
fboPixels.allocate(ofGetWidth(), ofGetHeight(), 8);

Next, I am using an FBO to render some graphics, then grabbing the FBO’s pixels and stuffing them into an ofImage in order to supply the ofxGifEncoder add-on with a set of pixels to save for each frame.

Right now, each frame is being saved automatically through a call in my update() function to the following code:


gifEncoder.addFrame(fboImage.getPixels(), ofGetWidth(), ofGetHeight(), 8, .25);

Finally, when I hit “s”, the GIF encoder add-on is directed to save the GIF like so:

case 's':
    cout <<"start saving\n" << endl;

When I run my program and hit the “s” key for the first time, I get the following message:

start saving

[warning] ofThread - name: Thread 1 - Calling startThread with verbose is deprecated.
gif saved as test.gif

Each subsequent time I hit ‘s’ I don’t get the [warning], only the first and last lines.

No gif file shows up in my bin/data folder and I don’t see it anywhere else either.

Any thoughts on what I’m doing wrong?

i think the pixels only needs 3 channels not 8, i think it gets reallocated in readToPixels though anyway

Changed it to 3 channels, but get the same result.

Interestingly, I left the window running for a while as I went to grab lunch, and when I came back the app had crashed and threw an error in the console mentioning a bad allocation.

In the meantime I’ve learned how to save images directly from frames in oF, so I can at least generate videos and GIFs from image sequences, though it is a little more work. No biggie, but still curious if this add-on can be made to work!

Yeah weird, I use ofxGifEncoder all the time and never had a problem.

My frame save line looks like this


where gifTmpStor is an oFImage with no alpha channel

Heres an example app I use

testApp.h (1.5 KB)
testApp.cpp (6.5 KB)