diff mbox series

[FFmpeg-devel,4/6] doc/examples/transcode: improve reporting when the encoder is not found

Message ID 20230901231447.1486347-4-stefasab@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/6] libavcodec/avcodec.h: fix typos in AVCodecContext.pkt_timebase description | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Stefano Sabatini Sept. 1, 2023, 11:14 p.m. UTC
Also return EINVAL in place of INVALIDDATA.
---
 doc/examples/transcode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paul B Mahol Sept. 3, 2023, 7:40 a.m. UTC | #1
On Sat, Sep 2, 2023 at 1:15 AM Stefano Sabatini <stefasab@gmail.com> wrote:

> Also return EINVAL in place of INVALIDDATA.
>

Better return also name, id number is meaningless to user.


> ---
>  doc/examples/transcode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
> index 1ec4a3c230..aa6594f4ec 100644
> --- a/doc/examples/transcode.c
> +++ b/doc/examples/transcode.c
> @@ -161,8 +161,8 @@ static int open_output_file(const char *filename)
>              /* in this example, we choose transcoding to same codec */
>              encoder = avcodec_find_encoder(dec_ctx->codec_id);
>              if (!encoder) {
> -                av_log(NULL, AV_LOG_FATAL, "Necessary encoder not
> found\n");
> -                return AVERROR_INVALIDDATA;
> +                av_log(NULL, AV_LOG_FATAL, "Necessary encoder with ID %d
> not found\n", dec_ctx->codec_id);
> +                return AVERROR(EINVAL);
>              }
>              enc_ctx = avcodec_alloc_context3(encoder);
>              if (!enc_ctx) {
> --
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index 1ec4a3c230..aa6594f4ec 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -161,8 +161,8 @@  static int open_output_file(const char *filename)
             /* in this example, we choose transcoding to same codec */
             encoder = avcodec_find_encoder(dec_ctx->codec_id);
             if (!encoder) {
-                av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
-                return AVERROR_INVALIDDATA;
+                av_log(NULL, AV_LOG_FATAL, "Necessary encoder with ID %d not found\n", dec_ctx->codec_id);
+                return AVERROR(EINVAL);
             }
             enc_ctx = avcodec_alloc_context3(encoder);
             if (!enc_ctx) {