The following patch adds a new audio filter, asettb, as suggested by
elenril on irc as an initial OPW task. It's ported from ffmpeg. Comments
are welcome.
It appears to work:
$ avconv -i /usr/share/doc/texlive-doc/latex/animate/files/click.mp3 -af
'ashowinfo,asettb=intb*2,ashowinfo' /tmp/test1.wav
avconv version v10_beta1-405-g3a5a965, Copyright (c) 2000-2014 the Libav
developers
built on Mar 31 2014 01:42:13 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, mp3, from
'/usr/share/doc/texlive-doc/latex/animate/files/click.mp3':
Metadata:
title : click
date : 2008
encoder : Lavf53.32.100
Duration: 00:00:00.13, start: 0.000000, bitrate: 157 kb/s
Stream #0.0: Audio: mp3, 44100 Hz, mono, s16p, 153 kb/s
Output #0, wav, to '/tmp/test1.wav':
Metadata:
INAM : click
ICRD : 2008
ISFT : Lavf55.14.0
Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 -> pcm_s16le)
Press ctrl-c to stop encoding
Input stream #0:0 frame changed from rate:44100 fmt:s16p ch:1 chl:mono to
rate:44100 fmt:s16 ch:1 chl:mono
[ashowinfo @ 0x2132300] n:0 pts:0 pts_time:0.000000 fmt:s16 chlayout:mono
rate:44100 nb_samples:1152 checksum:197CE276 plane_checksums: [ 197CE276 ]
[ashowinfo @ 0x2131560] n:0 pts:0 pts_time:0.000000 fmt:s16 chlayout:mono
rate:44100 nb_samples:1152 checksum:197CE276 plane_checksums: [ 197CE276 ]
[ashowinfo @ 0x2132300] n:1 pts:1152 pts_time:0.026122 fmt:s16
chlayout:mono rate:44100 nb_samples:1152 checksum:38306B6B plane_checksums:
[ 38306B6B ]
[ashowinfo @ 0x2131560] n:1 pts:576 pts_time:0.026122 fmt:s16 chlayout:mono
rate:44100 nb_samples:1152 checksum:38306B6B plane_checksums: [ 38306B6B ]
[ashowinfo @ 0x2132300] n:2 pts:2304 pts_time:0.052245 fmt:s16
chlayout:mono rate:44100 nb_samples:1152 checksum:EFFE2D51 plane_checksums:
[ EFFE2D51 ]
[ashowinfo @ 0x2131560] n:2 pts:1152 pts_time:0.052245 fmt:s16
chlayout:mono rate:44100 nb_samples:1152 checksum:EFFE2D51 plane_checksums:
[ EFFE2D51 ]
[ashowinfo @ 0x2132300] n:3 pts:3456 pts_time:0.078367 fmt:s16
chlayout:mono rate:44100 nb_samples:1152 checksum:8A7B15A0 plane_checksums:
[ 8A7B15A0 ]
[ashowinfo @ 0x2131560] n:3 pts:1728 pts_time:0.078367 fmt:s16
chlayout:mono rate:44100 nb_samples:1152 checksum:8A7B15A0 plane_checksums:
[ 8A7B15A0 ]
[ashowinfo @ 0x2132300] n:4 pts:4608 pts_time:0.104490 fmt:s16
chlayout:mono rate:44100 nb_samples:1152 checksum:F718CD1F plane_checksums:
[ F718CD1F ]
[ashowinfo @ 0x2131560] n:4 pts:2304 pts_time:0.104490 fmt:s16
chlayout:mono rate:44100 nb_samples:1152 checksum:F718CD1F plane_checksums:
[ F718CD1F ]
size= 11kB time=0.13 bitrate= 712.1kbits/s
video:0kB audio:11kB other streams:0kB global headers:0kB muxing overhead:
0.920139%
From 1854f3ecb0182624fda61f66878def701a8cbd2d Mon Sep 17 00:00:00 2001
From: [email protected]
Date: Mon, 31 Mar 2014 02:20:02 +0200
Subject: [PATCH] Added asettb support - setting timebases for audio
---
libavfilter/Makefile | 1 +
libavfilter/allfilters.c | 1 +
libavfilter/vf_settb.c | 60 ++++++++++++++++++++++++++++++++++++++++++------
3 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 5312c83..e66f4fa 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -28,6 +28,7 @@ OBJS-$(CONFIG_AFORMAT_FILTER) += af_aformat.o
OBJS-$(CONFIG_AMIX_FILTER) += af_amix.o
OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o
OBJS-$(CONFIG_ASETPTS_FILTER) += setpts.o
+OBJS-$(CONFIG_ASETTB_FILTER) += vf_settb.o
OBJS-$(CONFIG_ASHOWINFO_FILTER) += af_ashowinfo.o
OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index ddca153..d7bb47a 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -48,6 +48,7 @@ void avfilter_register_all(void)
REGISTER_FILTER(AMIX, amix, af);
REGISTER_FILTER(ANULL, anull, af);
REGISTER_FILTER(ASETPTS, asetpts, af);
+ REGISTER_FILTER(ASETTB, asettb, af);
REGISTER_FILTER(ASHOWINFO, ashowinfo, af);
REGISTER_FILTER(ASPLIT, asplit, af);
REGISTER_FILTER(ASYNCTS, asyncts, af);
diff --git a/libavfilter/vf_settb.c b/libavfilter/vf_settb.c
index 87b60a7..ec3e2d5 100644
--- a/libavfilter/vf_settb.c
+++ b/libavfilter/vf_settb.c
@@ -32,6 +32,7 @@
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/rational.h"
+#include "audio.h"
#include "avfilter.h"
#include "internal.h"
#include "video.h"
@@ -60,6 +61,15 @@ typedef struct {
double var_values[VAR_VARS_NB];
} SetTBContext;
+#define OFFSET(x) offsetof(SetTBContext, x)
+#define DEFINE_OPTIONS(filt_name, filt_type)
\
+static const AVOption filt_name##_options[] = {
\
+ { "expr", "set expression determining the output timebase",
OFFSET(tb_expr), AV_OPT_TYPE_STRING, {.str="intb"}, \
+ .flags=AV_OPT_FLAG_##filt_type##_PARAM },
\
+ { NULL }
\
+}
+
+
static int config_output_props(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
@@ -115,17 +125,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
*frame)
return ff_filter_frame(outlink, frame);
}
-#define OFFSET(x) offsetof(SetTBContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
-static const AVOption options[] = {
- { "expr", "Expression determining the output timebase", OFFSET(tb_expr),
AV_OPT_TYPE_STRING, { .str = "intb" }, .flags = FLAGS },
- { NULL },
-};
+DEFINE_OPTIONS(settb, VIDEO);
static const AVClass settb_class = {
.class_name = "settb",
.item_name = av_default_item_name,
- .option = options,
+ .option = settb_options,
.version = LIBAVUTIL_VERSION_INT,
};
@@ -159,3 +164,44 @@ AVFilter ff_vf_settb = {
.outputs = avfilter_vf_settb_outputs,
};
+
+
+#if CONFIG_ASETTB_FILTER
+
+DEFINE_OPTIONS(asettb, AUDIO);
+
+static const AVClass asettb_class = {
+ .class_name = "asettb",
+ .item_name = av_default_item_name,
+ .option = asettb_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+static const AVFilterPad avfilter_af_asettb_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .get_audio_buffer = ff_null_get_audio_buffer,
+ .filter_frame = filter_frame,
+ },
+ { NULL }
+};
+
+static const AVFilterPad avfilter_af_asettb_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .config_props = config_output_props,
+ },
+ { NULL }
+};
+
+AVFilter ff_af_asettb = {
+ .name = "asettb",
+ .description = NULL_IF_CONFIG_SMALL("Set timebase for the audio output
link."),
+ .priv_size = sizeof(SetTBContext),
+ .inputs = avfilter_af_asettb_inputs,
+ .outputs = avfilter_af_asettb_outputs,
+ .priv_class = &asettb_class,
+};
+#endif
--
1.8.3.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel