<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi,<br>
<br>
I'm in the process of migrating to libavfilter based resampling
using ffmpeg/libav 1.0 and the audio filter chain seems to be
introducing audio clicks. Setting up a passthrough chain with...<br>
<br>
AVFilterContext* last = NULL;<br>
filterAudGraph = avfilter_graph_alloc();<br>
<br>
char args[255]; <br>
snprintf(args, 255,
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%llx",
<br>
1, inpAudioCodec->sample_rate,
inpAudioCodec->sample_rate, <br>
av_get_sample_fmt_name(inpAudioCodec->sample_fmt),
inpAudioCodec->channel_layout);<br>
<br>
filterAudInp = tsUtilsInitFilter("abuffer", "audInput", args,
NULL, filterAudGraph);<br>
last = filterAudInp;<br>
<br>
const enum AVSampleFormat formats[] = { AV_SAMPLE_FMT_S16, -1 };<br>
AVABufferSinkParams* params = av_abuffersink_params_alloc();<br>
params->sample_fmts = formats;<br>
<br>
filterAudOut = tsUtilsInitFilter("ffabuffersink", "audOutput",
NULL, params, filterAudGraph);<br>
av_free(params);<br>
<br>
avfilter_link(last, 0, filterAudOut, 0);<br>
<br>
avfilter_graph_config(filterAudGraph, NULL);<br>
<br>
...where...<br>
<br>
AVFilterContext* tsUtilsInitFilter(const char * filterName, const
char* name, <br>
const char* arguments, void* opaque, AVFilterGraph* graph) {<br>
<br>
AVFilter* filter = avfilter_get_by_name(filterName);<br>
<br>
AVFilterContext* context = NULL;<br>
int ret = avfilter_graph_create_filter(&context, filter,
name, arguments, opaque, graph);<br>
if (ret < 0) {<br>
die("tsUtilsInitFilter - failed to create filter context
<%s>", name);<br>
}<br>
<br>
return context;<br>
<br>
}<br>
<br>
...however, when a frame is added (I believe the input sample
format, rate and channel layout is compatible with the required
output) who's first few samples look like this...<br>
<br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 <br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 ffffffff 00000000 00000000 00000000 00000000 00000000
00000000 00000000 <br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000001 00000000 00000001 00000000 00000000 00000000
00000000 00000000 <br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffffffff 00000000 <br>
ffffffff 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 <br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 <br>
<br>
...upon retrieving the same frame from the chain the first 4 samples
look somewhat different...<br>
<br>
<b>000063f0 ffffb628 00002ff8 000008d9</b> 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 <br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 ffffffff 00000000 00000000 00000000 00000000 00000000
00000000 00000000 <br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000001 00000000 00000001 00000000 00000000 00000000
00000000 00000000 <br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffffffff 00000000 <br>
ffffffff 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 <br>
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 <br>
<br>
...the remainder of the frame is identical. These sample dumps are
produced by...<br>
<br>
short* a = frame->data[0];<br>
for (int i = 0; i != frame->nb_samples; i++) {<br>
printf("%08x ", *(a++));<br>
if ((i % 16) == 15) printf("\n"); <br>
}<br>
<br>
....removing the filter chain and passing the decoded frames
straight through to the encoder does not produce clicking. Any
suggestions as to the cause would be gratefully received.<br>
<br>
<br>
Regards<br>
<br>
Ian <br>
</body>
</html>