• Ulrik Mikaelsson's avatar
    [codec context] Add decode_lazy() returning a generator · 9f3b4195
    Ulrik Mikaelsson authored
    Some codecs (VP9) can both buffer _many_ frames, and take a long time
    encoding each frame. Accumulated, the last `encode(None)`-flush can end
    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.
    9f3b4195