mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-06-19 19:03:00 +02:00
lavfi/overlay: implement shortest option
Force termination when the overlay stream ends. Simplify scripting logic, for example when an infinite source is used to generate a background for a composite video.
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
#define LIBAVFILTER_VERSION_MAJOR 3
|
||||
#define LIBAVFILTER_VERSION_MINOR 38
|
||||
#define LIBAVFILTER_VERSION_MICRO 104
|
||||
#define LIBAVFILTER_VERSION_MICRO 105
|
||||
|
||||
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
|
||||
LIBAVFILTER_VERSION_MINOR, \
|
||||
|
||||
@@ -91,6 +91,7 @@ typedef struct {
|
||||
int main_pix_step[4]; ///< steps per pixel for each plane of the main output
|
||||
int overlay_pix_step[4]; ///< steps per pixel for each plane of the overlay
|
||||
int hsub, vsub; ///< chroma subsampling values
|
||||
int shortest; ///< terminate stream when the shortest input terminates
|
||||
|
||||
char *x_expr, *y_expr;
|
||||
} OverlayContext;
|
||||
@@ -102,6 +103,7 @@ static const AVOption overlay_options[] = {
|
||||
{ "x", "set the x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||
{ "y", "set the y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||
{"rgb", "force packed RGB in input and output", OFFSET(allow_packed_rgb), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS },
|
||||
{ "shortest", "force termination when the shortest input terminates", OFFSET(shortest), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
|
||||
{NULL},
|
||||
};
|
||||
|
||||
@@ -560,6 +562,8 @@ static int request_frame(AVFilterLink *outlink)
|
||||
/* EOF on main is reported immediately */
|
||||
if (ret == AVERROR_EOF && input == OVERLAY) {
|
||||
over->overlay_eof = 1;
|
||||
if (over->shortest)
|
||||
return ret;
|
||||
if ((ret = try_filter_next_frame(ctx)) != AVERROR(EAGAIN))
|
||||
return ret;
|
||||
ret = 0; /* continue requesting frames on main */
|
||||
|
||||
Reference in New Issue
Block a user