Open CdRGit opened 5 years ago
Apparently yes :)
I just tried and it works. BUT it produces super fat GIFs. You should run gifsicle or change the encoding settings somehow to limit the file size. Probably limit the size, the frame rate, the number of colors, etc.
import com.hamoid.*;
VideoExport videoExport;
void setup() {
size(600, 600);
videoExport = new VideoExport(this, "haha.gif");
videoExport.setFfmpegVideoSettings(
new String[]{
"[ffmpeg]", // ffmpeg executable
"-y", // overwrite old file
"-f", "rawvideo", // format rgb raw
"-vcodec", "rawvideo", // in codec rgb raw
"-s", "[width]x[height]", // size
"-pix_fmt", "rgb24", // pix format rgb24
"-r", "[fps]", // frame rate
"-i", "-", // pipe input
"-an", // no audio
"-pix_fmt", "yuv420p", // color space yuv420p
"[output]" // output file
});
videoExport.startMovie();
}
void draw() {
background(#224488);
rect(frameCount * frameCount % width, 0, 40, height);
videoExport.saveFrame();
}
void keyPressed() {
if (key == 'q') {
videoExport.endMovie();
exit();
}
}
ps. the variables in square brackets (like [ffmpeg]
don't need to be changed, they are placeholders updated automatically by the library.
Running this for a few seconds produced a 25 Mb gif. Then I did
gifsicle --loop --delay=3 --colors 2 --optimize=2 haha.gif >haha2.gif
and the new file is just 400 Kb.
Would it be possible to have this library also export gifs?
Putting it as an issue since I can't comment on the processing forums. (No account)