summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-05-21 14:03:42 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-05-21 14:49:52 -0400
commitafeb3590fc5ff01d43b1a1be9df8fac64431ff9e (patch)
tree35ad32f8b80d374a83bc2601a1da2fc7e0892bc6
parentcc30080b3fb44bebea97533f7dfd5ee7700e4665 (diff)
lavfi: add an audio split filter
Based on current version of the asplit filter in FFmpeg written by Stefano Sabatini and others.
-rw-r--r--Changelog1
-rw-r--r--doc/filters.texi13
-rw-r--r--libavfilter/Makefile1
-rw-r--r--libavfilter/allfilters.c1
-rw-r--r--libavfilter/split.c30
-rw-r--r--libavfilter/version.h2
6 files changed, 45 insertions, 3 deletions
diff --git a/Changelog b/Changelog
index afde0e9e04..2da60b1166 100644
--- a/Changelog
+++ b/Changelog
@@ -19,6 +19,7 @@ version <next>:
- add libavresample audio conversion library
- audio filters support in libavfilter and avconv
- add fps filter
+- audio split filter
version 0.8:
diff --git a/doc/filters.texi b/doc/filters.texi
index cda235f106..ac780299b4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -137,6 +137,19 @@ aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
Pass the audio source unchanged to the output.
+@section asplit
+
+Split input audio into several identical outputs.
+
+The filter accepts a single parameter which specifies the number of outputs. If
+unspecified, it defaults to 2.
+
+For example
+@example
+avconv -i INPUT -filter_complex asplit=5 OUTPUT
+@end example
+will create 5 copies of the input audio.
+
@section asyncts
Synchronize audio data with timestamps by squeezing/stretching it and/or
dropping samples/adding silence when needed.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1a436d2877..8649222ed2 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -27,6 +27,7 @@ OBJS = allfilters.o \
OBJS-$(CONFIG_AFORMAT_FILTER) += af_aformat.o
OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o
+OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o
OBJS-$(CONFIG_RESAMPLE_FILTER) += af_resample.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index b3e57fd74c..316fff1798 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -36,6 +36,7 @@ void avfilter_register_all(void)
REGISTER_FILTER (AFORMAT, aformat, af);
REGISTER_FILTER (ANULL, anull, af);
+ REGISTER_FILTER (ASPLIT, asplit, af);
REGISTER_FILTER (ASYNCTS, asyncts, af);
REGISTER_FILTER (RESAMPLE, resample, af);
diff --git a/libavfilter/split.c b/libavfilter/split.c
index da6b3ff320..83ad765081 100644
--- a/libavfilter/split.c
+++ b/libavfilter/split.c
@@ -20,10 +20,11 @@
/**
* @file
- * Video splitter
+ * audio and video splitter
*/
#include "avfilter.h"
+#include "audio.h"
static int split_init(AVFilterContext *ctx, const char *args, void *opaque)
{
@@ -43,7 +44,7 @@ static int split_init(AVFilterContext *ctx, const char *args, void *opaque)
AVFilterPad pad = { 0 };
snprintf(name, sizeof(name), "output%d", i);
- pad.type = AVMEDIA_TYPE_VIDEO;
+ pad.type = ctx->filter->inputs[0].type;
pad.name = av_strdup(name);
avfilter_insert_outpad(ctx, i, &pad);
@@ -106,3 +107,28 @@ AVFilter avfilter_vf_split = {
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = NULL}},
};
+
+static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
+{
+ AVFilterContext *ctx = inlink->dst;
+ int i;
+
+ for (i = 0; i < ctx->output_count; i++)
+ ff_filter_samples(inlink->dst->outputs[i],
+ avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE));
+}
+
+AVFilter avfilter_af_asplit = {
+ .name = "asplit",
+ .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to N audio outputs."),
+
+ .init = split_init,
+ .uninit = split_uninit,
+
+ .inputs = (const AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .get_audio_buffer = ff_null_get_audio_buffer,
+ .filter_samples = filter_samples },
+ { .name = NULL }},
+ .outputs = (const AVFilterPad[]) {{ .name = NULL }},
+};
diff --git a/libavfilter/version.h b/libavfilter/version.h
index f352f7b242..f6497db364 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -29,7 +29,7 @@
#include "libavutil/avutil.h"
#define LIBAVFILTER_VERSION_MAJOR 2
-#define LIBAVFILTER_VERSION_MINOR 18
+#define LIBAVFILTER_VERSION_MINOR 19
#define LIBAVFILTER_VERSION_MICRO 0
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \