From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 85E2E4C223 for ; Wed, 30 Jul 2025 22:01:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 2AC0768CAD7; Thu, 31 Jul 2025 01:01:55 +0300 (EEST) Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id BB38168C4E4 for ; Thu, 31 Jul 2025 01:01:48 +0300 (EEST) Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-aec5a714ae9so29322066b.3 for ; Wed, 30 Jul 2025 15:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753912908; x=1754517708; darn=ffmpeg.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=MWCTW8um82ah/YHt/LzeCaSS9Vr5nAGMD5wPmuCbXiY=; b=aizhX1Bfoc87MtkJ31ooT9+Gu68J6LVXI7ZumnhLzU1GscUCrT9XqjGSn+Rh+LfkLh CuGVcM1rlhkD45iVkCZUyvhh99IryKkDNbnV1A0mPuJPkAhF6w/1lACvtpaGSmMoCZJS gJ+g8STWD/TqKzX2f2ac4nNY2Eso41ccqO0lMjincvbtXipX23sW6ICKpNyu/cKqgGVq 8W7jJBZFrxb+j2VGXW9j0ZMz7azfma27BPJtyvH0GFA7G4/TyuerlH5gHD96TycYaBNE qT/GjjXtD9bqy2ey5SJXu1RlyswDJDctVzPIKlPSORsBdsd+PEm0HqXzRmedT5Z0xrfe UDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753912908; x=1754517708; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MWCTW8um82ah/YHt/LzeCaSS9Vr5nAGMD5wPmuCbXiY=; b=qfHlFNdDSJWWn0Zm2rVKRwAuxFGCrSlyr71ACmuVubd080/7YD5S14m2eHMg1asKXG k5uaEKsaxsEhdhugZ3lI7hGaUoYA/USwh74OW7fs1JsMFs/BUTZZvVKnGTOoXlVsEaML Sbv0zAGmVE5GtLJNLRi3Sg6zltTOPZz2nic5C22sOY+nthe7mTrUQKd+7X9DDRgWY5QK fsGcK+spkACVol/7awfpqVK1B+CuJegSwOrOHsAHl6AK70TR/ixfv/MswKSw5WM3mvrv L4bDHTqEVFapZQhTiwI7S/zmvrdRglheDWktC0NLNpw+PriZoncVb2U+Ndm8RGU/RF5I fnjA== X-Gm-Message-State: AOJu0Yz3ZP3pqVGa3dY8Da1M9j5qVJBv7YPcdAgmgZpR3dmLVzcG6/yL rU3vDtuulzSBaZZIGn6Z8DVRFjaLp7Vb4a5dB0ca6K6WtzzUezWomlVy0M1wSFmk X-Gm-Gg: ASbGncsj7D6TrNwEfpFlWQfINeIr6Oc04mBXR57VksVowuJSCeNOs17Z9WVg4x/GfO1 jMlU+XWjdSuQWd+tVF3WdvawbCHqt5IVqymhW9EbtQRCQT4OgU0VPuaejka4Y2QcYgsR7KbPgiJ 3rHrW23ajMAtn9DCzye2aLpOT8eBKCzVRJozdkkWmw22znce2vfYjTRbpjWQLEHHMAvVUcV3VEX vuOtdrkHpn4Boi412o4SFk7ltc3qwh0cGuiXB9ub+DL4KZNKA0PO1LaLosywj+ZqZdazc4G00u3 EYHvyMiIDplEJZct45lGYQkzsPRb13lZWDaG7TD5xUl3Bge4Kvh+dlA5ddnMk8t+gRxbn3nWT7c MzwwDOqVjNh+smahkmIMKYXmxj3gxUKHgm6okHztfzzJp2gqD3qFZFQ4fZmp5Sg== X-Google-Smtp-Source: AGHT+IGJu1XBfmh82ZdqQbf+WssRbfYJgGHSZLosa5ByTEvKji45k4vTsBCTYYYa3PNr+BBuxanNDA== X-Received: by 2002:a17:907:7ba3:b0:ae6:c555:8dcf with SMTP id a640c23a62f3a-af8fd77be6emr633559366b.26.1753912907376; Wed, 30 Jul 2025 15:01:47 -0700 (PDT) Received: from mariano (dynamic-adsl-84-220-189-10.clienti.tiscali.it. [84.220.189.10]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-af91a0a3b6csm6413766b.48.2025.07.30.15.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 15:01:46 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id 828BFBFCE8; Thu, 31 Jul 2025 00:01:45 +0200 (CEST) Date: Thu, 31 Jul 2025 00:01:45 +0200 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches , Maryla Ustarroz-Calonge References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH v2] ffprobe: add -codec: option 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 Cc: Maryla Ustarroz-Calonge 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: On date Friday 2025-06-27 10:23:56 +0200, ffmpeg-devel Mailing List wrote: > From: Maryla Ustarroz-Calonge > Subject: [PATCH v2] ffprobe: add -codec: option > Date: Fri, 27 Jun 2025 10:23:56 +0200 > To: ffmpeg-devel@ffmpeg.org > X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog > > And -c: variant. > Update ffprobe.texi. > opt_codec() is mostly copied over from ffplay.c > > Signed-off-by: Maryla Ustarroz-Calonge > --- > Changelog | 2 +- > doc/ffprobe.texi | 8 ++++ > fftools/ffprobe.c | 117 +++++++++++++++++++++++++++++++++++++++++----- > 3 files changed, 114 insertions(+), 13 deletions(-) > > diff --git a/Changelog b/Changelog > index 4217449438..ae73611222 100644 > --- a/Changelog > +++ b/Changelog > @@ -18,7 +18,7 @@ version : > - APV encoding support through a libopenapv wrapper > - VVC decoder supports all content of SCC (Screen Content Coding): > IBC (Inter Block Copy), Palette Mode and ACT (Adaptive Color Transform > - > +- ffprobe -codec option > > version 7.1: > - Raw Captions with Time (RCWT) closed caption demuxer > diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi > index 8834df8d35..4ce0c8b583 100644 > --- a/doc/ffprobe.texi > +++ b/doc/ffprobe.texi > @@ -368,6 +368,14 @@ Read @var{input_url}. > Write output to @var{output_url}. If not specified, the output is sent > to stdout. > > +@item -c:@var{media_specifier} @var{codec_name} > +Force a specific decoder implementation for the stream identified by > +@var{media_specifier}, which can assume the values @code{a} (audio), > +@code{v} (video), @code{s} (subtitle), and @code{d} (data). > + > +@item -codec:@var{media_specifier} @var{codec_name} > +Alias for -c:@var{media_specifier}. Nit: I'd put the long version before the short one, but keep as is if this is consistent with the other docs. > + > @end table > @c man end > > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c > index 1346ed33c5..14ba4d3fb0 100644 > --- a/fftools/ffprobe.c > +++ b/fftools/ffprobe.c > @@ -36,6 +36,7 @@ > #include "libavutil/ambient_viewing_environment.h" > #include "libavutil/avassert.h" > #include "libavutil/avstring.h" > +#include "libavutil/avutil.h" > #include "libavutil/bprint.h" > #include "libavutil/channel_layout.h" > #include "libavutil/display.h" > @@ -130,6 +131,11 @@ static int use_byte_value_binary_prefix = 0; > static int use_value_sexagesimal_format = 0; > static int show_private_data = 1; > > +static const char *audio_codec_name = NULL; > +static const char *data_codec_name = NULL; > +static const char *subtitle_codec_name = NULL; > +static const char *video_codec_name = NULL; > + > #define SHOW_OPTIONAL_FIELDS_AUTO -1 > #define SHOW_OPTIONAL_FIELDS_NEVER 0 > #define SHOW_OPTIONAL_FIELDS_ALWAYS 1 > @@ -2284,6 +2290,64 @@ static void show_error(AVTextFormatContext *tfc, int err) > avtext_print_section_footer(tfc); > } > > +static int get_decoder_by_name(const char *codec_name, const AVCodec **codec) > +{ > + if (codec_name == NULL) > + return 0; > + > + *codec = avcodec_find_decoder_by_name(codec_name); > + if (*codec == NULL) { > + av_log(NULL, AV_LOG_ERROR, > + "No codec could be found with name '%s'\n", codec_name); > + return AVERROR(EINVAL); > + } > + return 0; > +} > + > +static int set_decoders(AVFormatContext *fmt_ctx) > +{ > + int ret; > + ret = get_decoder_by_name(audio_codec_name, &fmt_ctx->audio_codec); > + if (ret < 0) return ret; nit++: could be turned to a macro to capture the pattern: #define GET_DECODER(type_) \ ret = get_decoder_by_name(type_##_codec_name, &fmt_ctx->type_##_codec);\ if (ret < 0) return ret; GET_DECODER(audio); GET_DECODER(data); ... > + ret = get_decoder_by_name(data_codec_name, &fmt_ctx->data_codec); > + if (ret < 0) return ret; > + ret = get_decoder_by_name(subtitle_codec_name, &fmt_ctx->subtitle_codec); > + if (ret < 0) return ret; > + ret = get_decoder_by_name(video_codec_name, &fmt_ctx->video_codec); > + if (ret < 0) return ret; > + return 0; > +} > + Looks good apart from the minor nits, you can update the patch with the extended commit description otherwise I'd push this in a few days if there are no more comments. Thanks. _______________________________________________ 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".