Page 1 of 3

GifCat -- Write GIFs in LOVE.

Posted: Sun Jun 26, 2016 5:39 pm
by WetDesertRock
Hello all!

I have finally gotten around to releasing my GIF writing lib for LOVE 0.10.x, which I hope should be pretty easy to drop into your projects. One advantage this project has is that it is threaded (as much as possible), so it can save your gifs while you play with a minimal performance hit (even less if you give it a canvas rather than a screenshot).
1466962294.gif
1466962294.gif (413.36 KiB) Viewed 11301 times
Here is some code with all of the important bits cut out so you can see the basic API:

Code: Select all

-- In love.load()
gifcat.init()

-- In love.update()
gifcat.update(dt)

-- In love.quit()
gifcat.close()

-- Start recording:
curgif = gifcat.newGif(os.time()..".gif",100,100)

-- Write frame:
curgif:frame(love.graphics.newScreenshot())

-- Stop recording:
curgif:close()
https://github.com/WetDesertRock/GifCat

Re: GifCat -- Write GIFs in LOVE.

Posted: Sun Jun 26, 2016 7:50 pm
by zorg
Neat lib!

love.graphics.newScreenshot will impede performance no matter what, if called every frame; then again, this is good for "non-realtime" gif-renders, if one serializes all inputs and the game is deterministic; they can render replays to gifs to watch. (quality/filesize ratio might not be the best for that though) :3

Re: GifCat -- Write GIFs in LOVE.

Posted: Mon Jun 27, 2016 6:24 am
by Trebgarta
What about rendering to a canvas, and using that in both the screen and gifcat?

Re: GifCat -- Write GIFs in LOVE.

Posted: Mon Jun 27, 2016 8:27 am
by zorg
Trebgarta wrote:What about rendering to a canvas, and using that in both the screen and gifcat?
That may work better, didn't test it myself though, so can't say for certain.

Re: GifCat -- Write GIFs in LOVE.

Posted: Mon Jun 27, 2016 4:00 pm
by WetDesertRock
Trebgarta wrote:What about rendering to a canvas, and using that in both the screen and gifcat?
Yes, it will. :frame will work with ImageData, Image, or Canvas. So honestly .newScreenshot is probably the slowest (but easiest to demonstrate).

Re: GifCat -- Write GIFs in LOVE.

Posted: Thu Jun 30, 2016 12:41 am
by rmcode
I wanted to implement the library into LoGiVi, but no matter what I do the .so file can't be found:

Code: Select all

lib/gifcat/gifcat.lua:188: module 'gifcatlib' not found:
	no field package.preload['gifcatlib']
	no 'gifcatlib' in LOVE game directories.
	no file 'gifcatlib.so' in LOVE paths.
	no file './gifcatlib.lua'
	no file '/usr/local/share/luajit-2.0.3/gifcatlib.lua'
	no file '/usr/local/share/lua/5.1/gifcatlib.lua'
	no file '/usr/local/share/lua/5.1/gifcatlib/init.lua'
	no file './gifcatlib.so'
	no file '/usr/local/lib/lua/5.1/gifcatlib.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
I tried:

Code: Select all

local GIFLIB = "lib.gifcat.gifcatlib"
local GIFLIB = "lib/gifcat/gifcatlib"
local GIFLIB = "lib.gifcat"
local GIFLIB = "lib/gifcat"
... and a few more
I also moved both files to the same folder as my main, but even there it doesn't seem to find them :S

I just pushed the feature branch to the repo, in case you want to have a direct look at how things are organized.

Re: GifCat -- Write GIFs in LOVE.

Posted: Sat Jul 23, 2016 1:11 am
by WetDesertRock
rmcode: I just pushed a fix. Please try it out, note that your GIFLIB should now look like: "lib/gifcat/gifcatlib.so"

Re: GifCat -- Write GIFs in LOVE.

Posted: Sat Jul 23, 2016 2:59 am
by rmcode
Cool! It works now :)

Is there a way to specify the delay between frames?
Image
I tried it with frame:setFPS but that didn't seem to have the desired effect.

Re: GifCat -- Write GIFs in LOVE.

Posted: Sat Jul 23, 2016 6:09 am
by WetDesertRock
Without seeing your code I'll tell you this. It defaults it FPS to the current FPS when you are making a gif. However that FPS will most likely go down due to making a new gif. So I would suggest trying to pass a dt argument to the :frame function. Setting the FPS just interprets how fast the frames you are sending it are. So saying you are giving it 60 fps where in reality you are giving it 30 will result in a gif 2x as fast. The dt argument in :frame will make it a variable framerate, thus reacting to how fast the game is actually going.

Re: GifCat -- Write GIFs in LOVE.

Posted: Mon Sep 12, 2016 9:51 am
by PixelPiledriver
Yo, this looks awesome.
Would love to use it but I'm having some trouble.
Can't seem to build the library.
After a lot of different tries this is what I get.

Image

Not sure what to do.
Can you help me? :death: