Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] Add a friendly name to AVFormatContext (PR #21617)
Date: Sat, 31 Jan 2026 11:33:19 -0000
Message-ID: <176985920049.25.12518964313708840615@4457048688e7> (raw)

PR #21617 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21617
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21617.patch

This mirrors the design used to disambiguate log entries for AVFilterContext, by having `fftools/ffmpeg_demux.c` forward the demuxer instance name to the AVFormatContext. This includes the input format name (once known), mirroring the default log name; but with the extra input ID prefix.


>From ca456ed13765cab4a4f083f8416875678f138e8d Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Sat, 31 Jan 2026 11:50:34 +0100
Subject: [PATCH 1/2] avformat: add AVFormatContext.name

Analog to AVFilterContext. May be used to set a custom logging name to
disambiguate multiple AVFormatContext instances in the logs.
---
 doc/APIchanges         | 3 +++
 libavformat/avformat.c | 1 +
 libavformat/avformat.h | 5 +++++
 libavformat/options.c  | 3 ++-
 libavformat/version.h  | 4 ++--
 5 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ee3167bb14..59655434a7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
 
 API changes, most recent first:
 
+2026-02-xx - xxxxxxxxxx - lavf 62.9.100 - avformat.h
+  Add AVFormatContext.name.
+
 2026-01-xx - xxxxxxxxxx - lavu 60.24.100 - hwcontext_d3d11va.h
   Add BindFlags and MiscFlags to AVD3D11VADeviceContext
 
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index ee3f7ee1b2..806f8dcab2 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -190,6 +190,7 @@ void avformat_free_context(AVFormatContext *s)
     if (s->iformat)
         ff_flush_packet_queue(s);
     av_freep(&s->url);
+    av_freep(&s->name);
     av_free(s);
 }
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index bd34132e00..479f1f51c1 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1884,6 +1884,11 @@ typedef struct AVFormatContext {
      * @see skip_estimate_duration_from_pts
      */
     int64_t duration_probesize;
+
+    /**
+     * Name of this format context, only used for logging purposes.
+     */
+    char *name;
 } AVFormatContext;
 
 /**
diff --git a/libavformat/options.c b/libavformat/options.c
index 28aa2da942..d08013bfd4 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -45,7 +45,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 static const char* format_to_name(void* ptr)
 {
     AVFormatContext* fc = (AVFormatContext*) ptr;
-    if(fc->iformat) return fc->iformat->name;
+    if (fc->name) return fc->name;
+    else if(fc->iformat) return fc->iformat->name;
     else if(fc->oformat) return fc->oformat->name;
     else return fc->av_class->class_name;
 }
diff --git a/libavformat/version.h b/libavformat/version.h
index 1d3a53875a..1b079ebce8 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,8 +31,8 @@
 
 #include "version_major.h"
 
-#define LIBAVFORMAT_VERSION_MINOR   8
-#define LIBAVFORMAT_VERSION_MICRO 102
+#define LIBAVFORMAT_VERSION_MINOR   9
+#define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \
-- 
2.52.0


>From 565ebade18c4b132e117e86d85f51f6881432c83 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Sat, 31 Jan 2026 12:00:36 +0100
Subject: [PATCH 2/2] fftools/ffmpeg_demux: mirror DemuxStream name to
 AVFormatContext

Results in basically the same name, except less ambiguous because
it includes the input index.
---
 fftools/ffmpeg_demux.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 701f9ddc34..c8d8a7e044 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1879,6 +1879,7 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
     ic = avformat_alloc_context();
     if (!ic)
         return AVERROR(ENOMEM);
+    ic->name = av_strdup(d->log_name);
     if (o->audio_sample_rate.nb_opt) {
         av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate.opt[o->audio_sample_rate.nb_opt - 1].u.i, 0);
     }
@@ -1967,6 +1968,8 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
 
     av_strlcat(d->log_name, "/",               sizeof(d->log_name));
     av_strlcat(d->log_name, ic->iformat->name, sizeof(d->log_name));
+    av_freep(&ic->name);
+    ic->name = av_strdup(d->log_name);
 
     if (scan_all_pmts_set)
         av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2026-01-31 11:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=176985920049.25.12518964313708840615@4457048688e7 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /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