PR #21482 opened by Marton Balint (cus)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21482
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21482.patch
This reverts commit fcc33ada47e594d6b35b71c4a998af796f56492e.
It breaks playback of files with changing aspect ratio in ffplay, such as [1],
because the filter chain is initialized with the initial aspect ratio, so any
change is overwritten.
Michael already reported this issue at the time of patch submission [2], but it
was applied anyway.
Ideally we could reinitialize the filter chain, but we never wanted to do that
just for an aspect ratio change, because a filter chain reinitialization in the
middle of playback / encoding can cause even worse issues. So I think it is
better to just revert this.
[1]
https://samples.ffmpeg.org/archive/container/mpegts/mpegts+mpeg2video+mp2++aspect.ts
[2] https://ffmpeg.org/pipermail/ffmpeg-devel/2023-July/312175.html
>From b306cc24bf8d023d579b0637f58ce8cb0039cfb8 Mon Sep 17 00:00:00 2001
From: Marton Balint <[email protected]>
Date: Fri, 16 Jan 2026 00:11:57 +0100
Subject: [PATCH 1/2] avfilter: do not overwrite frame aspect ratio with source
frame props in histogram and vectorscrope
Signed-off-by: Marton Balint <[email protected]>
---
libavfilter/vf_histogram.c | 1 +
libavfilter/vf_vectorscope.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index f77148cdfe..1a5626b317 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -594,6 +594,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
}
av_frame_copy_props(out, in);
+ out->sample_aspect_ratio = outlink->sample_aspect_ratio;
av_frame_free(&in);
s->x_pos++;
if (s->x_pos >= s->width) {
diff --git a/libavfilter/vf_vectorscope.c b/libavfilter/vf_vectorscope.c
index eeee166172..483132332e 100644
--- a/libavfilter/vf_vectorscope.c
+++ b/libavfilter/vf_vectorscope.c
@@ -1469,6 +1469,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return AVERROR(ENOMEM);
}
av_frame_copy_props(out, in);
+ out->sample_aspect_ratio = outlink->sample_aspect_ratio;
s->vectorscope(s, in, out, s->pd);
s->graticulef(s, out, s->x, s->y, s->pd, s->cs);
--
2.52.0
>From 8b13e72ad8bb6c1d64606481049f7dbaf0c1cd85 Mon Sep 17 00:00:00 2001
From: Marton Balint <[email protected]>
Date: Wed, 14 Jan 2026 23:03:26 +0100
Subject: [PATCH 2/2] Revert "lavfi: make sure frame SAR matches the link
value"
This reverts commit fcc33ada47e594d6b35b71c4a998af796f56492e.
It breaks playback of files with changing aspect ratio in ffplay, such as [1],
because the filter chain is initialized with the initial aspect ratio, so any
change is overwritten.
[1]
https://samples.ffmpeg.org/archive/container/mpegts/mpegts+mpeg2video+mp2++aspect.ts
---
libavfilter/avfilter.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 169c2baa42..bb0b665f0c 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1084,8 +1084,6 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
if (av_pix_fmt_desc_get(link->format)->flags &
AV_PIX_FMT_FLAG_ALPHA)
av_assert1(frame->alpha_mode == link->alpha_mode);
}
-
- frame->sample_aspect_ratio = link->sample_aspect_ratio;
} else {
if (frame->format != link->format) {
av_log(link->dst, AV_LOG_ERROR, "Format change is not
supported\n");
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]