Some codecs (libvpx-vp9) can both buffer many frames, and take a long time encoding each frame. Accumulated, the last encode(None)
-flush can end up taking a long time >30s, without detectable progress.
FFmpeg and many encoders themselves output one frame at a time, but PyAV currently buffer them all up into lists returned.
This change adds a encode_lazy()
, yielding frames as they are made ready.
The change was benchmarked to also yield a net performance improvement. For both encode()
and encode_lazy
, encoding really small (24x18) frames using the mpeg4
encoder seem to take ~11% less time.