htfa.brainnet.write_animation¶
- htfa.brainnet.write_animation(images, out, fps=10)[source]¶
Write PIL images as an mp4 (H.264, yuv420p) or looping GIF, by suffix.
imagesmay be any iterable, such as a generator. An mp4 is written frame by frame as the iterable yields, so only one frame is held in memory at a time.GIFs use one palette for all frames (white, white-to-red and white-to-blue ramps, plus median-cut colors of all frames), without dithering, so colors do not flicker between frames. Choosing that palette needs every frame, so a GIF holds all frames in memory: about 4.8 MB per 1600 x 1000 frame (300 frames: about 1.4 GB). Use mp4 for long movies. Pillow stores identical consecutive GIF frames once, with their durations added, so such a GIF has fewer frames but the same running time.