Opened 7 years ago

Closed 5 years ago

#375 closed defect (fixed)

earwax audio filter generates wrong pts and af_sox filter can not be applied.

Reported by: chinshou Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: earwax
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by cehoyos)

Sorry, I do not know is it appropriate to report bug for audio filter branch at .

I just try the audio filter branch for a while and noticed that when i set -af earwax , the generated audio data pts always 0.
I added the avfilter_copy_buffer_ref_props(outref, insamples); call to copy original pts to new samplesref and it seems to fix the problem.

static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
    int16_t *taps, *endin, *in, *out;
    AVFilterBufferRef *outref =
        avfilter_get_audio_buffer(inlink, AV_PERM_WRITE,
+   avfilter_copy_buffer_ref_props(outref, insamples);//<<--copy pts

    taps  = ((EarwaxContext*)inlink->dst->priv)->taps;
    out   = (int16_t*)outref->data[0];
    in    = (int16_t*)insamples->data[0];

second, I guess we should add packing negotiate code to af_sox filter's query_formats , 
static int query_formats(AVFilterContext *ctx)
    AVFilterFormats *formats = NULL;
    avfilter_add_format(&formats, AV_SAMPLE_FMT_S32);
    avfilter_set_common_sample_formats(ctx, formats);
    avfilter_set_common_channel_layouts(ctx, avfilter_all_channel_layouts());
+    avfilter_set_common_packing_formats(ctx, avfilter_all_packing_formats());// << ---- packing negotiation

    return 0;

otherwise avfilter_graph_config call will fail at 
static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
            else if (link->type == AVMEDIA_TYPE_AUDIO) {
                if (!link->in_chlayouts || !link->out_chlayouts ||
                    !link->in_packing   || !link->out_packing)
                    return AVERROR(EINVAL); <<------fail at here

                if (!avfilter_merge_formats(link->in_formats,
                                            link->out_formats)    ||
                                            link->out_chlayouts)  ||

best regards

Change History (7)

comment:1 Changed 7 years ago by chinshou

Besides above problems,

in ffmpeg.c configure_audio_filters function should change inputs context from ost->input_audio_filter to last_filter like following.

static int configure_audio_filters(InputStream? *ist, OutputStream? *ost)

if (afilters) {

AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut));

*inputs = (AVFilterInOut){ av_strdup("out"), ost->output_audio_filter, 0, NULL };

*outputs = (AVFilterInOut){ av_strdup("in" ), ost->input_audio_filter, 0, NULL }; <<---remove this line

+ *outputs = (AVFilterInOut){ av_strdup("in" ), last_filter, 0, NULL }; <<--add this line

if ((ret = avfilter_graph_parse(ost->agraph, afilters, &inputs, &outputs, NULL)) < 0)

return ret;


} else {



Last edited 7 years ago by chinshou (previous) (diff)

comment:2 Changed 7 years ago by chinshou

another problem
in af_sox.c uninit will segfault when called, we should change it

static av_cold void uninit(AVFilterContext *ctx)

sox_effect_t *effect = ((SoxContext?*)ctx->priv)->effect;


static av_cold void uninit(AVFilterContext *ctx)

sox_effect_t *effect = ((SoxContext?*)ctx->priv)->effect;


comment:3 Changed 7 years ago by mnzaki

The packing negotiation is a new addition and it wasn't added to sox and earwax filter yet, ditto for the 'fail on missing negotiation data' behaviour, which might be changed...

copy_props and filter inputs/outputs will be fixed, thanks for the report!

comment:4 follow-up: Changed 5 years ago by michael

A long time has passed, earwax is now in git master, is anything from this ticket still relevant or can it be closed ?

comment:5 in reply to: ↑ 4 Changed 5 years ago by chinshou

Replying to michael:

A long time has passed, earwax is now in git master, is anything from this ticket still relevant or can it be closed ?


Please close this problem. The current earwax is ok.

best regards

comment:6 Changed 5 years ago by cehoyos

  • Description modified (diff)

comment:7 Changed 5 years ago by cehoyos

  • Keywords earwax added
  • Resolution set to fixed
  • Status changed from new to closed
  • Version changed from unspecified to git-master
Note: See TracTickets for help on using tickets.