[FFmpeg-devel] [PATCH 07/11] fftools/ffmpeg_filter: add AVOptions to OutputFilter
James Almer
jamrial at gmail.com
Tue Feb 18 15:08:09 EET 2025
Preparation work for the following commits.
Signed-off-by: James Almer <jamrial at gmail.com>
---
fftools/ffmpeg_filter.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 800e2a3f06..09086ca67c 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -640,10 +640,21 @@ static const char *ofilter_item_name(void *obj)
return ofp->log_name;
}
+static const AVOption ofilter_options[] = {
+ {"video_size", "set video size", offsetof(OutputFilterPriv, width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, INT_MAX },
+ {"pixel_format", "set pixel format", offsetof(OutputFilterPriv, format), AV_OPT_TYPE_PIXEL_FMT, {.i64 = AV_PIX_FMT_NONE}, -1, INT_MAX },
+ {"colorspace", "color space", offsetof(OutputFilterPriv, color_space), AV_OPT_TYPE_INT, {.i64 = AVCOL_SPC_UNSPECIFIED }, 0, INT_MAX },
+ {"color_range", "color range", offsetof(OutputFilterPriv, color_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED }, 0, INT_MAX },
+ {"ar", "set audio sampling rate (in Hz)", offsetof(OutputFilterPriv, sample_rate), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX },
+ {"ch_layout", NULL, offsetof(OutputFilterPriv, ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = NULL }, 0, 0 },
+ { NULL },
+};
+
static const AVClass ofilter_class = {
.class_name = "OutputFilter",
.version = LIBAVUTIL_VERSION_INT,
.item_name = ofilter_item_name,
+ .option = ofilter_options,
.parent_log_context_offset = offsetof(OutputFilterPriv, log_parent),
.category = AV_CLASS_CATEGORY_FILTER,
};
@@ -662,9 +673,7 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg, enum AVMediaType type)
ofp->log_parent = fg;
ofilter->graph = fg;
ofilter->type = type;
- ofp->format = -1;
- ofp->color_space = AVCOL_SPC_UNSPECIFIED;
- ofp->color_range = AVCOL_RANGE_UNSPECIFIED;
+ av_opt_set_defaults(ofp);
ofp->index = fg->nb_outputs - 1;
snprintf(ofp->log_name, sizeof(ofp->log_name), "%co%d",
--
2.48.1
More information about the ffmpeg-devel
mailing list