History

avfilter/af_silenceremove: add timestamp option

Paul B Mahol committed 3 years ago

Commit 62d41101 parent b95d1232 files · +27 −2Browse files

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/af_silenceremove.c+17−2
@@ -41,6 +41,12 @@ enum SilenceDetect { · 40 unmodified lines
41 D_NB41 D_NB
42};42};
43 43
44enum TimestampMode {
45 TS_WRITE,
46 TS_COPY,
47 TS_NB
48};
49
44enum ThresholdMode {50enum ThresholdMode {
45 T_ANY,51 T_ANY,
46 T_ALL,52 T_ALL,
@@ -67,6 +73,8 @@ typedef struct SilenceRemoveContext { · 20 unmodified lines
67 73
68 int64_t window_duration_opt;74 int64_t window_duration_opt;
69 75
76 int timestamp_mode;
77
70 int start_found_periods;78 int start_found_periods;
71 int stop_found_periods;79 int stop_found_periods;
72 80
@@ -138,6 +146,9 @@ static const AVOption silenceremove_options[] = { · 65 unmodified lines
138 { "median", "use median of absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_MEDIAN},0, 0, AF, "detection" },146 { "median", "use median of absolute values of samples", 0, AV_OPT_TYPE_CONST, {.i64=D_MEDIAN},0, 0, AF, "detection" },
139 { "ptp", "use absolute of max peak to min peak difference", 0, AV_OPT_TYPE_CONST, {.i64=D_PTP}, 0, 0, AF, "detection" },147 { "ptp", "use absolute of max peak to min peak difference", 0, AV_OPT_TYPE_CONST, {.i64=D_PTP}, 0, 0, AF, "detection" },
140 { "window", "set duration of window for silence detection", OFFSET(window_duration_opt), AV_OPT_TYPE_DURATION, {.i64=20000}, 0, 100000000, AF },148 { "window", "set duration of window for silence detection", OFFSET(window_duration_opt), AV_OPT_TYPE_DURATION, {.i64=20000}, 0, 100000000, AF },
149 { "timestamp", "set how every output frame timestamp is processed", OFFSET(timestamp_mode), AV_OPT_TYPE_INT, {.i64=TS_WRITE}, 0, TS_NB-1, AF, "timestamp" },
150 { "write", "full timestamps rewrite, keep only the start time", 0, AV_OPT_TYPE_CONST, {.i64=TS_WRITE}, 0, 0, AF, "timestamp" },
151 { "copy", "non-dropped frames are left with same timestamp", 0, AV_OPT_TYPE_CONST, {.i64=TS_COPY}, 0, 0, AF, "timestamp" },
141 { NULL }152 { NULL }
142};153};
143 154
@@ -293,7 +304,10 @@ static int filter_frame(AVFilterLink *outlink, AVFrame *in) · 149 unmodified lines
293 return AVERROR(ENOMEM);304 return AVERROR(ENOMEM);
294 }305 }
295 306
296 out->pts = s->next_pts;307 if (s->timestamp_mode == TS_WRITE)
308 out->pts = s->next_pts;
309 else
310 out->pts = in->pts;
297 311
298 switch (outlink->format) {312 switch (outlink->format) {
299 case AV_SAMPLE_FMT_FLT:313 case AV_SAMPLE_FMT_FLT:
@@ -395,7 +409,8 @@ static int activate(AVFilterContext *ctx) · 95 unmodified lines
395 if (ret > 0) {409 if (ret > 0) {
396 if (s->start_periods == 1 && s->stop_periods == 0 &&410 if (s->start_periods == 1 && s->stop_periods == 0 &&
397 s->start_found_periods < 0) {411 s->start_found_periods < 0) {
398 in->pts = s->next_pts;412 if (s->timestamp_mode == TS_WRITE)
413 in->pts = s->next_pts;
399 s->next_pts += in->nb_samples;414 s->next_pts += in->nb_samples;
400 return ff_filter_frame(outlink, in);415 return ff_filter_frame(outlink, in);
401 }416 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t