osci-render icon indicating copy to clipboard operation
osci-render copied to clipboard

Save Blender frames to file for later, standalone use (and improve performance while I'm at it)

Open DJLevel3 opened this issue 1 year ago β€’ 5 comments

New idea! I've had a look at the Blender plugin and how it sends data over, and I think it won't be too hard to add functionality to bake each frame to a file so osci-render can render them without Blender running every time. My plan at the moment is to use the file format RIFF and to store each frame individually, as this allows them to be mixed with other animations and other file types when opening a folder.

I'm planning to use RIFF, which is smaller and faster than JSON, as the Blender plugin has some performance issues when processing complex scenes. RIFF is a binary format, so the files will inherently be unreadable without a hex editor (I like to use hexed.it, if you're looking for one I recommend it). However, the data being stored is just a bunch of numbers anyway and the size and performance gains are significant.

DJLevel3 avatar Oct 14 '22 15:10 DJLevel3

This makes sense to me and completely agree that moving away from JSON is the right thing to do - I was aware of this when implementing but decided to go with the simple solution at first but now it's stable it makes sense to optimise a bit!

jameshball avatar Oct 14 '22 16:10 jameshball

All right, I've got a RIFF writer module coded for the Python side! I just need to integrate it into the Blender plugin and I'll have the saving side done. I coded the library to be useful for other things as well, it can be found in the PyRiff repo.

DJLevel3 avatar Oct 14 '22 18:10 DJLevel3

Also, at least in the benchmark I wrote, PyRiff is quite fast. Running on its own it can generate and write out a decently complex file with a number of different chunks in about 200 microseconds, or roughly 5000 times per second.

DJLevel3 avatar Oct 14 '22 18:10 DJLevel3

Blender side's done, working on the osci-render side. My idea is to use the ObjectSet class with a file parser rather than with the ObjectServer, which shouldn't be too difficult. Of course, we all know how that often goes lol

DJLevel3 avatar Oct 16 '22 15:10 DJLevel3

Luckily there's a Java library for reading the RIFF format so I don't have to write that.

DJLevel3 avatar Oct 16 '22 15:10 DJLevel3

#235 closes this

jameshball avatar Apr 28 '24 21:04 jameshball