Render to Video?
Hi, I've been using threepp several days now and it's great! This is a question rather than an issue: does threepp have a way to render to video? If not, has anyone done this, or could give a suggestion how I could implement it? Something with GLFW + FFMPEG capturing frames, perhaps?
I'm not sure what would be the more effective procedure here, but you do have the possibility to read the underlying pixel data from the GPU from the GLRenderer.
void readPixels(const Vector2& position, const WindowSize& size, Format format, unsigned char* data)
You may also copy the framebuffer into a texture. Demo
Thanks for the leads, Mark! I'll experiment with those and report back how it goes.
Rendering to video is surprisingly tricky and tends to bring in a lot of external dependencies. The solution for simple video files is something like gwavi [https://github.com/olegk0/libgwavi] which is a tiny library that lets you create AVI files from JPEG and PNG format images. It is pretty easy to convert the raw data from readPixels to JPEG in memory and then you can you can create MJPG movies. Not particularly modern but a widely readable format that is easy to edit. The AVIWriter.cpp class in GaitSym5 uses this and lets you write movies in just over 100 lines of code. It is using threecpp under Qt so it can let Qt do some of the conversion but it looks like threecpp can also do JPEG conversion in writeFramebuffer.