- r = avcodec_receive_frame (context, _frame);
- if (r == AVERROR(EAGAIN) || r == AVERROR_EOF) {
- /* More input is required, or no more frames are coming */
+ r = avcodec_receive_frame (context, _video_frame);
+ if (r == AVERROR(EAGAIN) || r == AVERROR_EOF || (r < 0 && !packet)) {
+ /* More input is required, no more frames are coming, or we are flushing and there was
+ * some error which we just want to ignore.
+ */