Any way to create animated GIFs straight out of love?
I have my replay system working now and would love to save a small GIF of that
Creating animated GIFs
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Creating animated GIFs
I'm not sure if this will help, but I found this:
https://ittner.github.io/lua-gd/manual.html
http://stackoverflow.com/questions/1664 ... 1#16649681
https://ittner.github.io/lua-gd/manual.html
http://stackoverflow.com/questions/1664 ... 1#16649681
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: Creating animated GIFs
You can make a screenshot and save it as a png every single frame and then make a gif from that.
Make sure to set a fixed frame length (don't use dt, but use a fixed time step to update your game).
Then you can use ffmpeg or imagemagick to glue it together:
Make sure to set a fixed frame length (don't use dt, but use a fixed time step to update your game).
Code: Select all
local frame = 0
function love.update( dt )
dt = 1/60 -- this way your gif will be at 60 fps
frame = frame + 1
local s = love.graphics.newScreenshot()
s:encode( string.format( "recording/%012d.png", frame ) )
end
Code: Select all
-- before closing your game you can run this if you have ffmpeg installed (don't know if this works on windows)
os.execute( "ffmpeg -i " .. love.filesystem.getSaveDirectory() .. "/recording/%012d.png " .. name )
-
- Citizen
- Posts: 63
- Joined: Tue Jan 14, 2014 11:03 pm
Re: Creating animated GIFs
I'm looking at a pure lua (or FFI) encoder, since this needs to run without any external tool.
Can't really find anything on the web, but there's a lot of javascript encoders that I can use as a reference. Will keep you posted if I can do or find something useful
Can't really find anything on the web, but there's a lot of javascript encoders that I can use as a reference. Will keep you posted if I can do or find something useful
Re: Creating animated GIFs
You could try "porting" this to the FFI: http://sydney.edu.au/engineering/it/~gr ... bgif/gif.c
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- zorg
- Party member
- Posts: 3449
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Creating animated GIFs
I have a semi-workable solution:
Let's assume that you can store the replay data, and can "replay" it without the need for it to run "realtime".
I realize this isn't the clearest explanation, i'll try to re-word it later if i have time.
Let's assume that you can store the replay data, and can "replay" it without the need for it to run "realtime".
- Your game records a replay.
- Replay is stored somewhere. (either in memory or dumped to the harddrive, or both)
- If the user wants to generate a gif of their run, have a function that simulates the game loop, but can take more time than when it would be played back in realtime.
- For each frame defined by the replay system, call love.graphics.newScreenshot (or if you're smart, render everything to a canvas in the above function, and get an imagedata from it.
- Use a 3rd party lib (either written in lua, or c and loaded in with the FFI) to create a GIF. The lib should be able to receive each frame separately though!
- Finally, export that final gif file.
I realize this isn't the clearest explanation, i'll try to re-word it later if i have time.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Creating animated GIFs
You do not have to worry about love.graphics.present, you can take a screenshot at the end of love.draw (so, before it). I've had similar concerns in the past, ended up calling it after love.graphics.present and everything was screwed up on pretty much any other PC, as the buffer was filled with garbage.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Creating animated GIFs
This was posted on itch.io a few days ago:
http://itch.io/t/12612/creating-a-gif-for-your-game
EDIT: argh ... didn't read the "directly out of löve" part
EDIT 2: aaaaaaan a double post for good measure
http://itch.io/t/12612/creating-a-gif-for-your-game
EDIT: argh ... didn't read the "directly out of löve" part
EDIT 2: aaaaaaan a double post for good measure
Who is online
Users browsing this forum: No registered users and 9 guests