I have an issue using FFMPEG.
avcodec_send_packet()
is returning error code -12.
I am trying to find what the meaning of -12 is.
I found this page but I can't understand the calculation for -12:
How can I find out what this ffmpeg error code means?
Can anyone help me?
I'm using DXVA2 for decoding. and avcodec_send_packet()
function is return -12 after the 20th frame.
20th frame return
21st frame return
If you read the avcodec_send_packet()
documentation, it says:
Returns
0 on success, otherwise negative error code:
AVERROR(EAGAIN)
: input is not accepted in the current state - user must read output withavcodec_receive_frame()
(once all output is read, the packet should be resent, and the call will not fail withEAGAIN
).AVERROR_EOF
: the decoder has been flushed, and no new packets can be sent to it (also returned if more than 1 flush packet is sent)AVERROR(EINVAL)
: codec not opened, it is an encoder, or requires flushAVERROR(ENOMEM)
: failed to add packet to internal queue, or similar other errors: legitimate decoding errors
Note that avcodec_send_packet()
is returning error codes based on the AVERROR()
macro, which is defined in libavutil/error.h
as:
/* error handling */
#if EDOM > 0
#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value.
#else
/* Some platforms have E* and errno already negated. */
#define AVERROR(e) (e)
#define AVUNERROR(e) (e)
#endif
As you can see in the documentation, standard POSIX error codes are being passed to AVERROR()
.
Now, if you go look at the POSIX error codes defined in your compiler's errno.h
header, you'll find that [-]12
is defined as ENOMEM
, which is one of the possible values mentioned in the avcodec_send_packet()
documentation:
AVERROR(ENOMEM)
: failed to add packet to internal queue, or similar other errors: legitimate decoding errors
Which, according to this version of error.h
(as opposed to this version) says:
#if LIBAVUTIL_VERSION_MAJOR < 51
#define AVERROR_INVALIDDATA AVERROR(EINVAL)
...
#define AVERROR_NOMEM AVERROR(ENOMEM)
...
#endif
The screenshots you have shown are testing the return value of avcodec_send_packet()
for AVERROR_INVALIDDATA
instead of AVERROR_NOMEM
.