Page 1 of 1

Encode an mp4?

Posted: Wed Jul 11, 2018 11:13 pm
by NetherGranite
Is there a way to use love2d to encode mp4s or other video formats, or is the most one could do simply to encode many png files and then use an external program to stitch them into a video? Or is there even a Lua library out there for doing this?

Edit: I realized it was not exactly clear what I meant. I was wondering if there was a way to use love2d to draw each frame, but instead of just outputting each frame to the screen, outputting each frame to a function that would encode it into an mp4 file. In fact, I don't necessarily need a love2d-specific way to do this; I just need a Lua way to do it. Is there a library out there capable of this?

Re: Encode an mp4?

Posted: Thu Jul 12, 2018 3:49 pm
by Link
I'm unsure of your goal; to make a video from PNG files try FFMPEG: https://trac.ffmpeg.org/wiki/Slideshow

If you're looking to create a video of gameplay footage, use https://obsproject.com/ to capture your screen & audio while you play.

Re: Encode an mp4?

Posted: Thu Jul 12, 2018 8:25 pm
by NetherGranite
Link wrote: Thu Jul 12, 2018 3:49 pm I'm unsure of your goal
Sorry, I just realized that my question was not clear. I was wondering how one would go about using love2d to draw each frame but instead of merely outputting each frame to the screen, outputting each frame to a function that would encode it into an mp4 file. I have added clarification to it.

Re: Encode an mp4?

Posted: Thu Jul 12, 2018 10:15 pm
by pgimeno
LÖVE supports Ogg Theora video decoding, but I don't think it supports any form of video encoding. Saving one image per frame to encode them into a video later sounds like one way to go. Using a video capturing tool that captures from the screen would be another.

Re: Encode an mp4?

Posted: Fri Jul 13, 2018 11:24 am
by zorg
If anything, i'd just code my game to be able to save deterministic replays, since that can be done much faster than saving each rendered frame, and one could either export the recreated frames "off-line", as png images and combined together with an external program, like ffmpeg, or one could theoretically include ffmpeg in their project and maybe use FFI to access its functions so it automatically would do that for you.