korlibs / korge

KorGE Game Engine. Multiplatform Kotlin Game Engine
https://korge.org/
Other
2.47k stars 123 forks source link

FR: ffmpeg support #960

Open Kietyo opened 1 year ago

Kietyo commented 1 year ago

JS: https://github.com/Kagami/ffmpeg.js/

JVM and Native could be a wrapper on ffmpeg directly: https://ffmpeg.org/

soywiz commented 1 year ago

For typical platforms we could consider using native functionality: video for the web is easy, then in android, iOS and macos we have common functionality. In windows I believe there are APIs too, and in linux we could use stdin/stdout from ffmpeg and depend on the binary.

At some point I would want to make a C/C++/any WASM to KMM converter. In the JVM it should be possible to conver WASM directly into JVM bytecode either at runtime or build time, we could do the same for C++: either build the library directly in C++ or convert a WASM module into C code and provide it as part of the klib. Maybe we can convert it into plain C and put it in the .def file. And for JS it is possible to load a WASM file directly and use it asynchronously.

So the idea would be compile ffmpeg into a WASM module. And then make a WASM to KMM library converter. This is a pretty big sideproject that might be worth it for the long term. Maybe we can find some people online willing to help, we can ask in the Kotlin slack, and that have the same idea to work on that. If not, we can create that project as part of the korlibs if nobody started it already.

soywiz commented 1 year ago

Related: https://github.com/korlibs/korge/issues/535 , https://github.com/korlibs/korge/issues/563