Commit eada463e9a for ffmpeg
commit eada463e9a06385c1b1df0f4a8484f3954c67277
Author: Niklas Haas <git@haasn.dev>
Date: Wed Oct 28 14:52:56 2026 +0100
avfilter/vf_libplacebo: add sar option
Forces the output sample aspect ratio, instead of deriving it from the
input.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
diff --git a/doc/filters.texi b/doc/filters.texi
index 37f9123df4..cc2b28a72b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17190,6 +17190,10 @@ content with black borders, while a value of @code{1.0} always crops off parts
of the content. Intermediate values are possible, leading to a mix of the two
approaches.
+@item sar
+Force the output sample aspect ratio. The default of @code{0} derives it from
+the input, see @option{reset_sar}.
+
@item fit_mode
Specify the content fit strategy according to a list of predefined modes.
Determines how the input image is to be placed inside the destination crop
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 0c2b309bd3..a0b4d29585 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -186,6 +186,7 @@ typedef struct LibplaceboContext {
int force_divisible_by;
int reset_sar;
int normalize_sar;
+ AVRational out_sar;
int fit_mode;
int fit_sense;
int apply_filmgrain;
@@ -1635,6 +1636,9 @@ static int libplacebo_config_output(AVFilterLink *outlink)
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
}
+ if (s->out_sar.num)
+ outlink->sample_aspect_ratio = s->out_sar;
+
/* Frame rate */
if (s->fps.num) {
ol->frame_rate = s->fps;
@@ -1680,6 +1684,7 @@ fail:
#define OPTS_COMMON \
{ "format", "Output video format", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = STATIC }, \
+ { "sar", "Output sample aspect ratio (0 for automatic)", OFFSET(out_sar), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, INT_MAX, STATIC }, \
{ "inherit_device", "Inherit the Vulkan device from the input's hardware frames context", \
OFFSET(inherit_device), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, .flags = STATIC }, \
{ "shader_cache", "Set shader cache path", OFFSET(shader_cache), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = STATIC }, \