produce: Flush remaining frames when we are deactivating
- produce: Flush remaining frames when we are deactivating
When we deactivate, we may still have a bunch of frames in FFmpeg's filter or encode queues. Currently, if that happens, we simply discard those frames and tear everything down, which results in files missing several frames that were actually recorded.
To avoid that, if we know we still have frames in the queues, wait with teardown until we know all frames have been processed.
This does mean setActive(false)
can take a while to complete since the
queues might have a large amount of frames remaining, but fixing that
properly requires a different API.