Issue was caused by incorrect FFmpeg asynchronous decoding API. In most
cases, decoder returns 1 frame each time it is fed by 1 packet. Here
decoder wanted to return more frames, but our code always expected only
one.
Add buffer for frame storage.
Now decoding follows this scheme:
- Feed decoder by 1 packet
- Try to get frame
- If frame is ready, use it as usual, but try to get more frames in loop and store them in buffer.
- If frame is not ready, quit. Since decoding is run in loop, eventually frame will be returned, unless error occurs.
I think this could be simplified by not using any buffer, will make separate patch for this. Or if it turns out to be terrible idea I will mention this.
This bug originates in 2.93, so it should be discussed if this should be backported to LTS, I think for 3.0 this is fairly safe.