@@ -3817,7 +3817,7 @@ avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi
# programs
ffmpeg_deps="avcodec avfilter avformat"
ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
- hflip_filter null_filter
+ snull_filter strim_filter hflip_filter null_filter
transpose_filter trim_filter vflip_filter"
ffmpeg_suggest="ole32 psapi shell32"
ffplay_deps="avcodec avformat swscale swresample sdl2"
@@ -581,7 +581,9 @@ OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o
# subtitle filters
OBJS-$(CONFIG_CENSOR_FILTER) += sf_textmod.o
OBJS-$(CONFIG_SHOW_SPEAKER_FILTER) += sf_textmod.o
+OBJS-$(CONFIG_SNULL_FILTER) += sf_snull.o
OBJS-$(CONFIG_SPLITCC_FILTER) += sf_splitcc.o
+OBJS-$(CONFIG_STRIM_FILTER) += trim.o
OBJS-$(CONFIG_STRIPSTYLES_FILTER) += sf_stripstyles.o
OBJS-$(CONFIG_SUBFEED_FILTER) += sf_subfeed.o
OBJS-$(CONFIG_SUBSCALE_FILTER) += sf_subscale.o
@@ -573,7 +573,9 @@ extern const AVFilter ff_avsrc_movie;
extern const AVFilter ff_sf_censor;
extern const AVFilter ff_sf_graphicsub2text;
extern const AVFilter ff_sf_showspeaker;
+extern const AVFilter ff_sf_snull;
extern const AVFilter ff_sf_splitcc;
+extern const AVFilter ff_sf_strim;
extern const AVFilter ff_sf_stripstyles;
extern const AVFilter ff_sf_subfeed;
extern const AVFilter ff_sf_subscale;
new file mode 100644
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2021 softworkz
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * null subtitle filter
+ */
+
+#include "avfilter.h"
+#include "internal.h"
+#include "libavutil/internal.h"
+
+static const AVFilterPad avfilter_sf_snull_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ },
+};
+
+static const AVFilterPad avfilter_sf_snull_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ },
+};
+
+const AVFilter ff_sf_snull = {
+ .name = "snull",
+ .description = NULL_IF_CONFIG_SMALL("Pass the source unchanged to the output."),
+ .flags = AVFILTER_FLAG_METADATA_ONLY,
+ FILTER_INPUTS(avfilter_sf_snull_inputs),
+ FILTER_OUTPUTS(avfilter_sf_snull_outputs),
+};
@@ -83,7 +83,7 @@ static int config_input(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
TrimContext *s = ctx->priv;
- AVRational tb = (inlink->type == AVMEDIA_TYPE_VIDEO) ?
+ AVRational tb = (inlink->type != AVMEDIA_TYPE_AUDIO) ?
inlink->time_base : (AVRational){ 1, inlink->sample_rate };
if (s->start_time != INT64_MAX) {
@@ -369,3 +369,47 @@ const AVFilter ff_af_atrim = {
FILTER_OUTPUTS(atrim_outputs),
};
#endif // CONFIG_ATRIM_FILTER
+
+#if CONFIG_STRIM_FILTER
+
+#define FLAGS (AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
+static const AVOption strim_options[] = {
+ COMMON_OPTS
+ { "start_frame", "Number of the first frame that should be passed "
+ "to the output", OFFSET(start_frame), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, FLAGS },
+ { "end_frame", "Number of the first frame that should be dropped "
+ "again", OFFSET(end_frame), AV_OPT_TYPE_INT64, { .i64 = INT64_MAX }, 0, INT64_MAX, FLAGS },
+ { NULL }
+};
+#undef FLAGS
+
+AVFILTER_DEFINE_CLASS(strim);
+
+static const AVFilterPad strim_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ .filter_frame = trim_filter_frame,
+ .config_props = config_input,
+ },
+};
+
+static const AVFilterPad strim_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ },
+};
+
+const AVFilter ff_sf_strim = {
+ .name = "strim",
+ .description = NULL_IF_CONFIG_SMALL("Pick one continuous section from the input, drop the rest."),
+ .init = init,
+ .priv_size = sizeof(TrimContext),
+ .priv_class = &strim_class,
+ .flags = AVFILTER_FLAG_METADATA_ONLY,
+ FILTER_INPUTS(strim_inputs),
+ FILTER_OUTPUTS(strim_outputs),
+};
+#endif // CONFIG_STRIM_FILTER
+