[FFmpeg-devel] [RFC] Internal error messages

Nicolas George george at nsup.org
Thu Dec 31 15:36:40 EET 2020


This mail is about a project I have to make FFmpeg's API and
infrastructure more convenient. For a common introduction, see this thread:
https://ffmpeg.org/pipermail/ffmpeg-devel/2020-December/274167.html

The way we currently report errors is fine for command-line tools running in
a terminal, but it does not suit GUI applications at all: they will get a
generic error, translated into a vague string like "invalid argument", while
a more precise error message that tells which argument is invalid and how
will go to the log, and disappear in a black-hole like ~/.xsession-errors or
even /dev/null; at best, the application will have registered a log callback
and display the whole log to the user.

I want to add a new API to return an error all at once, something like this:

    if (... failure condition...)
        return av_error_set(ctx, AVERROR_INVALIDDATA,
                            "Syntax error in file ${file} line ${line}",
                            "file", finename,
                            "line", av_d2str(line),
                            NULL);

The complete error message will be stored into a pre-allocated AVErrorStatus
structure in the context, and can be then retrieved by the application
using:

    av_error_get(ctx, buf);

and displayed to the user in any convenient way (dialog box, HTTP response,
etc.).

For compatibility, av_log(ctx, ...) will not only print to stderr, but also
keep the last line(s) of log in the AVErrorStatus buffer in ctx, so that
code that still does the good old:

        av_log(ctx, AV_LOG_ERROR, "Syntax error in file %s line %d\n",
               filename, line);
        return AVERROR_INVALIDDATA;

will now work ok with av_error_get().

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20201231/be12c38f/attachment.sig>


More information about the ffmpeg-devel mailing list