Encode a sequence of images into video

Hi! A key feature in my current game is recording videos of the screen. I’ve already manage to build a pretty decent library that is able to save screenshots at certain fps without affecting the game performance at all. Now I need to encode those stills into a video.
What do you consider the best way to follow? I need a cross platform solution that can do all the job inside the app, not depending on external apps or program.
I’ve consider ffmpeg but it’s not Java and I think it wouldn’t be so trivial to wrap it in Java and port it to Android and iOS.
There is a (not so good) Java library called JCodec that runs on desktop and Android, too. But I don’t know how well it will behave on iOS and it’s pretty limited.
And I’ve even consider using gdx-video because I think it wraps some of ffmpeg functionality, but if i’m not wrong it’s only able to decode and I don’t know if it runs on iOS (and there isn’t so much documentation)
Do you know any almost native solutions for each platform? What path would you take?

Thank you in advance! Any idea (even vague) will be appreciate!

If you are familiar with how to write JNI libraries, I would recommend making a binding for libx265/HEVC, if you don’t need a whole array of different video/audio/subtitle codecs in your game and want to keep things small. libx265 has a very decent build process, also working out of the box on Windows/msvc. No other library I know of has this ability. :slight_smile:
If you need multiple such codecs then FFmpeg really is the best shot there is.
libav is not worth talking about. It is goddamn slow.
If you choose FFmpeg then there is Xuggler, which provides a JNI binding more or less with a custom API for FFmpeg.
And you would need to build FFmpeg for each of your target platforms.
For iOS there seems to be: https://github.com/kewlbear/FFmpeg-iOS-build-script
For Windows this one is great: https://github.com/rdp/ffmpeg-windows-build-helpers
Or if you don’t want to build yourself on Windows, then Zeranoe is of course the solution: http://ffmpeg.zeranoe.com/builds/

I’ve used FFMpeg to do pretty much exactly what you’re describing. It wasn’t very hard. Here is an explanation of what I did. You’d just need to get rid of all my OpenCV stuff and substitute your own screenshots in.

i still have to try it out by myself … last time i looked for java flick encoding i ran into https://github.com/artclarke/humble-video which looks pretty interesting.

o/