[FFmpeg-devel] [PATCH] libavfilter/f_select: response file support
Hello :-) I had a project recently where I wanted to externally specify a list of specific frame numbers to drop. I understand this can be done with select expressions like "not(eq(n,45)+eq(n,47)+eq(n,75))", but in my case I wanted to drop nearly 16,000 frames, which would have required a command-line over 250 KB in size. I chose a different approach: I have added functionality to f_select.c so that you can specify the list of frames you want to include/exclude in an external response file. I have successfully used this code for my project, and thought I might submit it up to for consideration. :-) I've never submitted a patch in this format before, I hope I'm doing this correctly. Thanks very much, Jonathan Gilbert --- libavfilter/f_select.c | 316 - 1 file changed, 310 insertions(+), 6 deletions(-) diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c index 1132375758..0852fffb44 100644 --- a/libavfilter/f_select.c +++ b/libavfilter/f_select.c @@ -22,6 +22,8 @@ * @file * filter for selecting which frame passes in the filterchain */ +#include +#include #include "libavutil/avstring.h" #include "libavutil/eval.h" @@ -139,10 +141,33 @@ enum var_name { VAR_VARS_NB }; +enum filemode { +SELECT_FILEMODE_INCLUDE, +SELECT_FILEMODE_EXCLUDE +}; + +enum filetype { +SELECT_FILETYPE_FRAMENO, +SELECT_FILETYPE_PTS +}; + +enum warnunused { +SELECT_WARNUNUSED_NO, +SELECT_WARNUNUSED_YES, +SELECT_WARNUNUSED_ALL +}; + typedef struct SelectContext { const AVClass *class; char *expr_str; AVExpr *expr; +char *file_str; +int *file_frame_list; +int file_frame_list_length; +enum filemode filemode; +enum filetype filetype; +char *file_frame_list_used; +enum warnunused file_warn_unused; double var_values[VAR_VARS_NB]; int do_scene_detect;///< 1 if the expression requires scene detection variables, 0 otherwise ff_scene_sad_fn sad;///< Sum of the absolute difference function (scene detect only) @@ -158,6 +183,17 @@ typedef struct SelectContext { static const AVOption filt_name##_options[] = { \ { "expr", "set an expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags=FLAGS }, \ { "e","set an expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags=FLAGS }, \ +{ "file", "set the name of a file from which frame numbers are read", OFFSET(file_str), AV_OPT_TYPE_STRING, { .str = "" }, .flags=FLAGS }, \ +{ "filemode", "set the interpretation of the file (include or exclude)", OFFSET(filemode), AV_OPT_TYPE_INT, { .i64 = SELECT_FILEMODE_INCLUDE }, INT_MIN, INT_MAX, FLAGS, "filemode" }, \ +{ "include", "include all frames listed in the file", 0, AV_OPT_TYPE_CONST, { .i64 = SELECT_FILEMODE_INCLUDE }, INT_MIN, INT_MAX, FLAGS, "filemode" }, \ +{ "exclude", "exclude all frames listed in the file", 0, AV_OPT_TYPE_CONST, { .i64 = SELECT_FILEMODE_EXCLUDE }, INT_MIN, INT_MAX, FLAGS, "filemode" }, \ +{ "filetype", "set the interpretation of the file (frameno or pts)", OFFSET(filetype), AV_OPT_TYPE_INT, { .i64 = SELECT_FILETYPE_FRAMENO }, INT_MIN, INT_MAX, FLAGS, "filetype" }, \ +{ "frameno", "match frames by frame number", 0, AV_OPT_TYPE_CONST, { .i64 = SELECT_FILETYPE_FRAMENO }, INT_MIN, INT_MAX, FLAGS, "filetype" }, \ +{ "pts", "match frames by pts", 0, AV_OPT_TYPE_CONST, { .i64 = SELECT_FILETYPE_PTS }, INT_MIN, INT_MAX, FLAGS, "filetype" }, \ +{ "warnunused", "if enabled, warns if any of the frame numbers from the input file are never matched", OFFSET(file_warn_unused), AV_OPT_TYPE_INT, { .i64 = SELECT_WARNUNUSED_NO }, INT_MIN, INT_MAX, FLAGS, "warnunused" }, \ +{ "no", "do not warn about unused frame numbers from the input file", 0, AV_OPT_TYPE_CONST, { .i64 = SELECT_WARNUNUSED_NO }, INT_MIN, INT_MAX, FLAGS, "warnunused" }, \ +{ "yes", "warn about unused frame numbers from the input file, but don't show a long list", 0, AV_OPT_TYPE_CONST, { .i64 = SELECT_WARNUNUSED_YES }, INT_MIN, INT_MAX, FLAGS, "warnunused" }, \ +{ "all", "warn about all unused frame numbers from the input file, even if there are many", 0, AV_OPT_TYPE_CONST, { .i64 = SELECT_WARNUNUSED_ALL }, INT_MIN, INT_MAX, FLAGS, "warnunused" }, \ { "outputs", "set the number of outputs", OFFSET(nb_outputs), AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, .flags=
Re: [FFmpeg-devel] [PATCH] libavfilter/f_select: response file support
I've changed the allocation functions and attached the output of `git format-patch` to this e-mail. Thanks, Jonathan Gilbert On Tue, Apr 16, 2019 at 5:50 PM Carl Eugen Hoyos wrote: > 2019-04-16 19:14 GMT+02:00, Jonathan Gilbert : > > Hello :-) > > > > I had a project recently where I wanted to externally specify a list > > of specific frame numbers to drop. I understand this can be done with > > select expressions like "not(eq(n,45)+eq(n,47)+eq(n,75))", but in my > > case I wanted to drop nearly 16,000 frames, which would have required > > a command-line over 250 KB in size. I chose a different approach: I > > have added functionality to f_select.c so that you can specify the > > list of frames you want to include/exclude in an external response > > file. I have successfully used this code for my project, and thought I > > might submit it up to for consideration. :-) > > > > I've never submitted a patch in this format before, I hope I'm doing > > this correctly. > > This is definitely not the only issue: > Instead of using malloc() and friends, please see libavutil/mem.h > for the appropriate functions. > > Carl Eugen > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". 0001-Added-options-file-filemode-filetype-and-warnunused-.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavfilter/f_select: response file support
Ping! :-) Thanks, Jonathan Gilbert On Wed, Apr 17, 2019 at 4:18 AM Jonathan Gilbert wrote: > I've changed the allocation functions and attached the output of `git > format-patch` to this e-mail. > > Thanks, > > Jonathan Gilbert > > On Tue, Apr 16, 2019 at 5:50 PM Carl Eugen Hoyos > wrote: > >> 2019-04-16 19:14 GMT+02:00, Jonathan Gilbert : >> > Hello :-) >> > >> > I had a project recently where I wanted to externally specify a list >> > of specific frame numbers to drop. I understand this can be done with >> > select expressions like "not(eq(n,45)+eq(n,47)+eq(n,75))", but in my >> > case I wanted to drop nearly 16,000 frames, which would have required >> > a command-line over 250 KB in size. I chose a different approach: I >> > have added functionality to f_select.c so that you can specify the >> > list of frames you want to include/exclude in an external response >> > file. I have successfully used this code for my project, and thought I >> > might submit it up to for consideration. :-) >> > >> > I've never submitted a patch in this format before, I hope I'm doing >> > this correctly. >> >> This is definitely not the only issue: >> Instead of using malloc() and friends, please see libavutil/mem.h >> for the appropriate functions. >> >> Carl Eugen >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] tiny documentation fix
Hello, I found a mistake in the documentation, a parameter that was copy/pasted but not updated. In filters.texi, the documentation for the colorcorrect filter describes "rh" as "red highlight spot" and "bh" also as "red highlight spot". I'm reasonably confident it should say "blue highlight spot". https://github.com/FFmpeg/FFmpeg/compare/master...logiclrd:FFmpeg:patch-1 Do with this information what you will. :-) Thanks, Jonathan Gilbert ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".