encoding: Track the number of frames in flight
If the encoder cannot keep up, we can run into cases where either the filter or encode queues are filling up with frames, causing memory usage to increase unconstrained. Unfortunately, FFMpeg does not have any way to set limits on its internal queues. So instead, we manually track frames enqueued and dequeued so that we can drop frames should the queues fill up too fast.