Audio-resampling isn't actually performed?

Lusine lusinehayrapetyan1992 at
Thu Nov 12 11:16:54 UTC 2020

Hi Folks,
Thanks for your feedback. My element is based on GstAudioAggregator and it's
pretty simple - I only overwrite base aggregate function in my element.
I have 2 input streams and in aggregate function "based on some condition" I
want to output only one stream.  Lets say I have a counter and change which
sink pad to output every 100 iteration. This is the code:

static int current_id = 0;
static int count = 0;
static GstFlowReturn aggregate(GstAggregator * agg, gboolean timeout)
    GstFlowReturn ret;
    gboolean pad_eos = false;
    GstBuffer *outbuf = NULL;
    for (size_t i = 0; i < g_list_length(GST_ELEMENT(agg)->sinkpads); ++i)
        GstAggregatorPad *aggpad = (GstAggregatorPad *)
(g_list_nth_data(GST_ELEMENT(agg)->sinkpads, i));
        pad_eos = gst_aggregator_pad_is_eos(aggpad);
        if (!pad_eos)
           // Choose one pad and drop the other one.
            if (i == current_id)
                outbuf = gst_aggregator_pad_pop_buffer(aggpad);
// Change the sink pad after 100 iteration. It means output 2 seconds audio
from first sink pad
// then 2 seconds of audio from second sink pad, then again 2 second audio
from first and etc.
    count ++;
    if (count == 100)
        count = 0;
        current_id ++;
        if (current_id == 2)
            current_id = 0;

    if (!pad_eos && outbuf)
        ret = gst_aggregator_finish_buffer(agg, outbuf);
       ret = GST_FLOW_EOS;
    return ret;

It  works correctly when both my inputs(sink pads) have the same audio rate
but in case of inputs have different sample rates I get the following error
message even though I do resampling(bringing to the same audio rate with
audioresample) before passing to the audio aggregator element:

ERROR                  qtmux gstqtmux.c:4535:gst_qt_mux_add_buffer:
decreasing DTS value 0:00:08.845333332 < 0:00:18.612919076

Please let me know what I'm missing. Why this code works when my input files
have the same audio rate and why I get this error when both my inputs have
different rates even though I resample the audio streams to the same rate
with audioresample element before passing them to my custom plugin.
Sorry for the long question.


Sent from:

More information about the gstreamer-devel mailing list