PR #24455 opened by ffmpeg-devel
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24455
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24455.patch

**Backport:** https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24247

Two fixes for the ffmpeg CLI.

**First commit**

The capital V specifier as in '-c:V' is supposed to match only non-attached-pic 
video streams. However, a user reported that apic streams were matched as well.
Confirmed by testing. Apparently a regression since before v3.4 (earliest ver I 
could test).

This happens because encoder selection occurs before stream dispositions are 
set. Fixed by setting disposition before other spec options are applied.

----
**Second commit**
(withdrawn for now, as a few FATE samples seem to want to set multiple streams 
of same media type as default)

The current implementation of fn set_dispositions lets multiple streams of the 
same media type be marked as default streams.

The function is reworked to give precedence to user-assigned default 
disposition. Singular default disposition per media type is enforced.
Function is renamed to make its primary role clearer.


>From befe04e0dc8d102ec0aa131c30ea1c219d54fb68 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <[email protected]>
Date: Wed, 9 Sep 2026 10:30:46 +0530
Subject: [PATCH] ffmpeg: fix matching of non-apic stream specifiers

The capital V specifier as in '-c:V' is supposed to match only non-attached-pic 
video streams.

However, a user reported that apic streams were matched as well.
Confirmed by testing. Apparently a regression since before 3.4 (earliest ver I 
could test).

This happens because encoder selection occurs before stream dispositions are 
set.

Fixed by an initial assignment of disposition and retaining only the apic flag 
if present.

PR #24247

(cherry picked from commit 266fff15a0f5e1165a90327ecacae82e7df107c9)
---
 fftools/ffmpeg_mux_init.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 17977eb07f..39c485e57b 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1192,7 +1192,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
     int threads_manual = 0;
     AVRational enc_tb = { 0, 0 };
     enum VideoSyncMethod vsync_method = VSYNC_AUTO;
-    const char *bsfs = NULL, *time_base = NULL, *codec_tag = NULL;
+    const char *bsfs = NULL, *time_base = NULL, *codec_tag = NULL, 
*manual_disp = NULL;
     char  *next;
     double qscale = -1;
 
@@ -1249,6 +1249,20 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
     ms->par_in->codec_type   = type;
     st->codecpar->codec_type = type;
 
+    if (ost->type == AVMEDIA_TYPE_VIDEO) {
+        if (ost->ist)
+            ost->st->disposition = ost->ist->st->disposition;
+
+        opt_match_per_stream_str(ost, &o->disposition, oc, st, &manual_disp);
+        if (manual_disp) {
+            ret = av_opt_set(ost->st, "disposition", manual_disp, 0);
+            if (ret < 0)
+                return ret;
+        }
+
+        ost->st->disposition &= AV_DISPOSITION_ATTACHED_PIC;
+    }
+
     ret = choose_encoder(o, oc, ms, &enc);
     if (ret < 0) {
         av_log(ost, AV_LOG_FATAL, "Error selecting an encoder\n");
@@ -3038,6 +3052,11 @@ static int set_dispositions(Muxer *mux, const 
OptionsContext *o)
     if (!dispositions)
         return AVERROR(ENOMEM);
 
+    // reset any apic flag set for option stream-spec matching in ost_add
+    for (int i = 0; i < ctx->nb_streams; i++) {
+        of->streams[i]->st->disposition = 0;
+    }
+
     // first, copy the input dispositions
     for (int i = 0; i < ctx->nb_streams; i++) {
         OutputStream *ost = of->streams[i];
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to