export video from love2d
export video from love2d
I'm new to Love2D, and I want to generate a video via love2D's rendering engine. Is there a way to render code directly into a video instead of running it in a window? Thanks!!
Re: export video from love2d
Hi, I think the closest thing is the Canvas type, used for off-screen rendering. See these:
- https://love2d.org/wiki/Canvas
- https://love2d.org/wiki/Canvas:newImageData (a copy of the pixels in the canvas as an ImageData type)
- https://love2d.org/wiki/ImageData:encode (saving that ImageData as a file)
This means you'd capture an image sequence to files and later on encode them to a video using a different program.
A fallback in case this isn't working for you is to use OBS or some other screen recorder app to capture the main LÖVE window, like Youtube or Twitch streamers do.
- https://love2d.org/wiki/Canvas
- https://love2d.org/wiki/Canvas:newImageData (a copy of the pixels in the canvas as an ImageData type)
- https://love2d.org/wiki/ImageData:encode (saving that ImageData as a file)
This means you'd capture an image sequence to files and later on encode them to a video using a different program.
A fallback in case this isn't working for you is to use OBS or some other screen recorder app to capture the main LÖVE window, like Youtube or Twitch streamers do.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: export video from love2d
Adding to the above answer, you could modify love.run to assure that update and draw get called at constant time intervals, so that the output frame rate won't fluctuate (that is to say, the visuals won't).
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: export video from love2d
In theory you could render the frames in a loop - it doesn't have to be in real time.
Either way it's important to use a "fixed time step"
Re: export video from love2d
Expanding on the ImageData idea, a simple solution is to use love.graphics.captureScreenshot to capture each frame. No canvas required. Of course, none of these methods capture any sound. Your best bet is probably to use an external recording program as LÖVE indeed does not provide a way to encode video files.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: export video from love2d
Gotta promote my internal-use library: use ls2x.
Or you can pipe FFmpeg, but pipe bandwidth in Windows is not that great.
Code: Select all
local ls2x = require("ls2x")
local ffi = require("ffi")
local function supply(imageData)
ls2x.libav.supplyEncoder(ffi.cast("uint8_t*", imageData:getFFIPointer()))
end
function love.load()
ls2x.libav.startEncodingSession("output_File.mkv", love.graphics.getWidth(), love.graphics.getHeight(), 60) -- 60 = 60 FPS
end
function love.update(dt)
-- set dt to constant
game_update(constant_dt)
love.graphics.captureScreenshot(supply)
end
-- your love.draw goes below
function love.quit()
ls2x.libav.endEncodingSession()
end
Profile. Do you encounter crashes in LÖVE Android and wanna send me logcats? Please hit me up in LÖVE Discord and send the full logcat file!
Re: export video from love2d
That looks dope AuahDark. I consider myself good at googling and couldn't find any Lua video encoding libraries, I wonder how I missed your ls2x. Very useful.
Re: export video from love2d
I want to create a game with this platform. The idea of my game is a girl locked in a house and she has to follow the instructions of the users who see her live through the webcam and I need an external program to make screen recordings, it doesn't matter that it doesn't capture the sound, but I can't find one that is simple, could you recommend one?
Who is online
Users browsing this forum: Google [Bot] and 5 guests