Python PIL image.save() performance hit

Hi,

I’m using the Python PIL (Pillow) module’s PIL.Image.save() method every few seconds through a timer CHOP’s callback and every time this particular method gets called I see TD’s framerate drop with a noticeable stutter in the playback of all other parts of the project. The file I’m saving to disk is a 400x3000 PNG with alpha that weighs < 200kB. This is running on a pretty speedy 4GHz quad Xeon with SSDs, ample RAM, Quadro graphics cards etc.

I’m sure I’ll find another way around this probably by avoiding saving to disk and keeping everything in memory instead but this got me wondering about how tasks running on the CPU (such as execs) are threaded within TD and how they might affect other tasks running on the GPU and ultimately affect playback.

  • Any general thoughts or traps to avoid when making heavier use of Python within TD?
  • Is there a “better” way of passing images being generated or modified through Python back into TD tops besides files?

Thanks!

If you are not refferencing any TD stuff, you can try to thread the whole saving project not impacting the main thread.
The bump in FPS is, as TD waits for the process of saving the file to complete before proceeding with the rest.
Maybe you can try using a the moviefileoutTOP instead.

There is also an ‘async’ parameter in the save() method for TOPs that will do the file saving in another thread, helping avoid the performance hit.