From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4631A46144 for ; Fri, 7 Jul 2023 09:51:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5396D68C834; Fri, 7 Jul 2023 12:49:27 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 562FD68C7E2 for ; Fri, 7 Jul 2023 12:49:07 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2E8792405B5 for ; Fri, 7 Jul 2023 11:49:04 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 4Hm0IUWo473x for ; Fri, 7 Jul 2023 11:49:03 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id C4A9B2404F8 for ; Fri, 7 Jul 2023 11:49:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6A7FA3A1251 for ; Fri, 7 Jul 2023 11:48:54 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jul 2023 11:48:30 +0200 Message-Id: <20230707094847.25324-5-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230707094847.25324-1-anton@khirnov.net> References: <20230707094847.25324-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/22] lavc/encode: improve unsupported-format error messages X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Mention encoder name in the message to emphasize that the value in question is not supported by this specific encoder, not necessarily by libavcodec in general. Print a list of values supported by the encoder. --- libavcodec/encode.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 9a279d9842..ee501132da 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -565,8 +565,16 @@ static int encode_preinit_video(AVCodecContext *avctx) if (avctx->pix_fmt == c->pix_fmts[i]) break; if (c->pix_fmts[i] == AV_PIX_FMT_NONE) { - av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is not supported\n", - av_get_pix_fmt_name(avctx->pix_fmt)); + av_log(avctx, AV_LOG_ERROR, + "Specified pixel format %s is not supported by the %s encoder.\n", + av_get_pix_fmt_name(avctx->pix_fmt), c->name); + + av_log(avctx, AV_LOG_ERROR, "Supported pixel formats:\n"); + for (int p = 0; c->pix_fmts[p] != AV_PIX_FMT_NONE; p++) { + av_log(avctx, AV_LOG_ERROR, " %s\n", + av_get_pix_fmt_name(c->pix_fmts[p])); + } + return AVERROR(EINVAL); } if (c->pix_fmts[i] == AV_PIX_FMT_YUVJ420P || @@ -652,8 +660,16 @@ static int encode_preinit_audio(AVCodecContext *avctx) } } if (c->sample_fmts[i] == AV_SAMPLE_FMT_NONE) { - av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is not supported\n", - av_get_sample_fmt_name(avctx->sample_fmt)); + av_log(avctx, AV_LOG_ERROR, + "Specified sample format %s is not supported by the %s encoder\n", + av_get_sample_fmt_name(avctx->sample_fmt), c->name); + + av_log(avctx, AV_LOG_ERROR, "Supported sample formats:\n"); + for (int p = 0; c->sample_fmts[p] != AV_SAMPLE_FMT_NONE; p++) { + av_log(avctx, AV_LOG_ERROR, " %s\n", + av_get_sample_fmt_name(c->sample_fmts[p])); + } + return AVERROR(EINVAL); } } @@ -662,8 +678,14 @@ static int encode_preinit_audio(AVCodecContext *avctx) if (avctx->sample_rate == c->supported_samplerates[i]) break; if (c->supported_samplerates[i] == 0) { - av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n", - avctx->sample_rate); + av_log(avctx, AV_LOG_ERROR, + "Specified sample rate %d is not supported by the %s encoder\n", + avctx->sample_rate, c->name); + + av_log(avctx, AV_LOG_ERROR, "Supported sample rates:\n"); + for (int p = 0; c->supported_samplerates[p]; p++) + av_log(avctx, AV_LOG_ERROR, " %d\n", c->supported_samplerates[p]); + return AVERROR(EINVAL); } } @@ -675,8 +697,15 @@ static int encode_preinit_audio(AVCodecContext *avctx) if (!c->ch_layouts[i].nb_channels) { char buf[512]; int ret = av_channel_layout_describe(&avctx->ch_layout, buf, sizeof(buf)); - av_log(avctx, AV_LOG_ERROR, "Specified channel layout '%s' is not supported\n", - ret > 0 ? buf : "?"); + av_log(avctx, AV_LOG_ERROR, + "Specified channel layout '%s' is not supported by the %s encoder\n", + ret > 0 ? buf : "?", c->name); + + av_log(avctx, AV_LOG_ERROR, "Supported channel layouts:\n"); + for (int p = 0; c->ch_layouts[p].nb_channels; p++) { + ret = av_channel_layout_describe(&c->ch_layouts[p], buf, sizeof(buf)); + av_log(avctx, AV_LOG_ERROR, " %s\n", ret > 0 ? buf : "?"); + } return AVERROR(EINVAL); } } -- 2.40.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".