mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-24 02:09:03 +03:00
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 266fff15a0)
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user