Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use avcodec_receive_frame? #43

Closed
ghost opened this issue May 8, 2018 · 1 comment
Closed

How to use avcodec_receive_frame? #43

ghost opened this issue May 8, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented May 8, 2018

I have a simple app with this decoding method:

      ```
      static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
      {
      int ret;
      *got_frame = 0;
      if (pkt) 
      {
                ret = avcodec_send_packet(avctx, pkt);
                if (ret < 0) 
                {
                          return ret == AVERROR_EOF ? 0 : ret;
                }
      }
      ret = avcodec_receive_frame(avctx, frame);
      if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) 
      {
                return ret;
      }
      if (ret >= 0)
      {
                *got_frame = 1;
      }
      return 0;
      }

I use this method to store video clip but there are a few frames in the video clip with errors or 'miss frames' from previous clip.

avcodec_receive_frame(avctx, frame); - returns code '-11' that stands for 'other negative values: legitimate decoding errors'. What the 'other negative values' are?

@h4tr3d
Copy link
Owner

h4tr3d commented Aug 30, 2018

Sorry for delay. Just reference to official docs:

and new send/receive API overview:

In short: all (or most) codecs has "delay": count of frames/packet that should be pushed to the codec before first packet/frame received. Obviously, codec context has some queue. So, when pipeline restarts, you must flush this queue by sending some special data.

@h4tr3d h4tr3d closed this as completed Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant