Commit b5314333 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/af_adelay: make it possible to delay channels by exact number of samples

parent 0ed5c3ce
...@@ -513,6 +513,7 @@ Set list of delays in milliseconds for each channel separated by '|'. ...@@ -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. At least one delay greater than 0 should be provided.
Unused delays will be silently ignored. If number of given delays is Unused delays will be silently ignored. If number of given delays is
smaller than number of channels all remaining channels will not be delayed. 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 @end table
@subsection Examples @subsection Examples
...@@ -524,6 +525,13 @@ the second channel (and any other channels that may be present) unchanged. ...@@ -524,6 +525,13 @@ the second channel (and any other channels that may be present) unchanged.
@example @example
adelay=1500|0|500 adelay=1500|0|500
@end example @end example
@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.
@example
adelay=0|500S|700S
@end example
@end itemize @end itemize
@section aecho @section aecho
......
...@@ -138,14 +138,20 @@ static int config_input(AVFilterLink *inlink) ...@@ -138,14 +138,20 @@ static int config_input(AVFilterLink *inlink)
for (i = 0; i < s->nb_delays; i++) { for (i = 0; i < s->nb_delays; i++) {
ChanDelay *d = &s->chandelay[i]; ChanDelay *d = &s->chandelay[i];
float delay; float delay;
char type = 0;
int ret;
if (!(arg = av_strtok(p, "|", &saveptr))) if (!(arg = av_strtok(p, "|", &saveptr)))
break; break;
p = NULL; 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) { if (d->delay < 0) {
av_log(ctx, AV_LOG_ERROR, "Delay must be non negative number.\n"); av_log(ctx, AV_LOG_ERROR, "Delay must be non negative number.\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment