Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Stefano Sabatini <stefasab@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Maryla Ustarroz-Calonge <maryla@google.com>
Subject: Re: [FFmpeg-devel] [PATCH v2] ffprobe: add -codec:<media_spec> option
Date: Thu, 31 Jul 2025 00:01:45 +0200
Message-ID: <aIqWSZxvJBAFw1Z6@mariano> (raw)
In-Reply-To: <mailman.4658.1751012645.1384.ffmpeg-devel@ffmpeg.org>

On date Friday 2025-06-27 10:23:56 +0200, ffmpeg-devel Mailing List wrote:
> From: Maryla Ustarroz-Calonge <maryla@google.com>
> Subject: [PATCH v2] ffprobe: add -codec:<media_spec> 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:<media_spec> variant.
> Update ffprobe.texi.
> opt_codec() is mostly copied over from ffplay.c
> 
> Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com>
> ---
>  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 <next>:
>  - 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".

  parent reply	other threads:[~2025-07-30 22:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27  8:23 Maryla Ustarroz-Calonge via ffmpeg-devel
2025-07-10 16:29 ` Maryla Ustarroz via ffmpeg-devel
2025-07-11 22:06   ` Michael Niedermayer
2025-07-25 13:36     ` Maryla Ustarroz via ffmpeg-devel
2025-07-30 22:01 ` Stefano Sabatini [this message]
2025-07-31 11:54   ` Maryla Ustarroz via ffmpeg-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aIqWSZxvJBAFw1Z6@mariano \
    --to=stefasab@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=maryla@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git