[FFmpeg-cvslog] avfilter/af_adelay: make it possible to delay channels by exact number of samples
Paul B Mahol
git at videolan.org
Thu Aug 11 22:46:30 EEST 2016
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Aug 11 21:42:56 2016 +0200| [b5314333dee195a53f3dd84c7394fd3c3ee82bb4] | committer: Paul B Mahol
avfilter/af_adelay: make it possible to delay channels by exact number of samples
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5314333dee195a53f3dd84c7394fd3c3ee82bb4
---
doc/filters.texi | 8 ++++++++
libavfilter/af_adelay.c | 10 ++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 8cef0a0..f43465d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -513,6 +513,7 @@ Set list of delays in milliseconds for each channel separated by '|'.
At least one delay greater than 0 should be provided.
Unused delays will be silently ignored. If number of given delays is
smaller than number of channels all remaining channels will not be delayed.
+If you want to delay exact number of samples, append 'S' to number.
@end table
@subsection Examples
@@ -524,6 +525,13 @@ the second channel (and any other channels that may be present) unchanged.
@example
adelay=1500|0|500
@end example
+
+ at item
+Delay second channel by 500 samples, the third channel by 700 samples and leave
+the first channel (and any other channels that may be present) unchanged.
+ at example
+adelay=0|500S|700S
+ at end example
@end itemize
@section aecho
diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
index 09bf3c7..187cacf 100644
--- a/libavfilter/af_adelay.c
+++ b/libavfilter/af_adelay.c
@@ -138,14 +138,20 @@ static int config_input(AVFilterLink *inlink)
for (i = 0; i < s->nb_delays; i++) {
ChanDelay *d = &s->chandelay[i];
float delay;
+ char type = 0;
+ int ret;
if (!(arg = av_strtok(p, "|", &saveptr)))
break;
p = NULL;
- sscanf(arg, "%f", &delay);
- d->delay = delay * inlink->sample_rate / 1000.0;
+ ret = sscanf(arg, "%d%c", &d->delay, &type);
+ if (ret != 2 || type != 'S') {
+ sscanf(arg, "%f", &delay);
+ d->delay = delay * inlink->sample_rate / 1000.0;
+ }
+
if (d->delay < 0) {
av_log(ctx, AV_LOG_ERROR, "Delay must be non negative number.\n");
return AVERROR(EINVAL);
More information about the ffmpeg-cvslog
mailing list