Pipeline freeze when audio source is ended

stic at free.fr stic at free.fr
Thu Aug 10 11:52:50 UTC 2017

Thanks a lot Michael for your answer.
This is also something I tried but I failed to get it working.
As you already described I tried to use a blocking probe to replace the audio source (a uridecodebin) by a fakesrc in order to keep having audio buffers in the pipeline.
I also had to post a GstMessage on the bus to make the removal of the audio source and replacement by fakesrc on the main thread (message callback).
After your message I tried again hard but I still fail...

Do you think I can use fakesrc to send empty audio buffer on the pipeline to replace the audio source, or should I use something else ?

I am also wondering when the blocking pad should be unblocked ? Should it be unblocked from the message callback (the callback function receiving the GstMessage) ?
If so how could this be done ?

Here is the code I am using for blocking pad and message callback function:

/*** callback function receiving the GstMessage to replace the audio source ***/
/* Retrieve application custom messages from the bus */
static void application_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
    // look for object coming from the audio source only
    if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->asource) && gst_message_has_name (msg, "asourceReplace")) {
        // application message from audio source, the message means the elements received EOS and needs to be replaced

        // stop element to remove
        gst_element_set_state (data->asource, GST_STATE_NULL);
        // remove unlinks automatically
        GST_DEBUG_OBJECT (data->pipeline, "removing %" GST_PTR_FORMAT, data->asource);
        gst_bin_remove (GST_BIN (data->pipeline), data->asource);
        // add a new fakesink
        data->asource = gst_element_factory_make ("fakesrc", "asource");
        if (G_IS_OBJECT(data->asource)) g_object_set (G_OBJECT (data->asource), "is-live", TRUE, NULL);
        gst_bin_add (GST_BIN (data->pipeline), data->asource);
        // link fakesink
        gst_element_link (data->asource, data->audioSourceQueue);

        gst_element_sync_state_with_parent (data->asource);

/*** Callback function from blocking probe ***/
static GstPadProbeReturn
audio_source_event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
    CustomData *data = (CustomData *)user_data;

        return GST_PAD_PROBE_PASS;

    gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));

    // we need to remove asource and replace it, this can only be done asynchronously, so we post a message on the bus for it
    GstBus *bus = gst_element_get_bus (data->pipeline);
    if (GST_IS_BUS(bus)) {
        gst_bus_post(bus, gst_message_new_application(GST_OBJECT(data->asource), gst_structure_new_empty("asourceReplace")));

    return GST_PAD_PROBE_DROP; // unblock from here or can it be done from application_cb ?

----- Mail original -----
De: "Michael MacIntosh" <mmacintosh at linear-systems.com>
À: gstreamer-devel at lists.freedesktop.org
Envoyé: Mercredi 9 Août 2017 21:19:24
Objet: Re: Pipeline freeze when audio source is ended


If you have an audio and a video source being fed into a muxer, and 
assuming you can't get around the source producing the EOS, then you 
probably want to drop the EOS signal, and use a blocking probe to 
disconnect the old source and replace it with a source that would 
produce "silence", because most video file formats expect both streams 
to be the same length.

But the problem you are running into is the muxer will block your video 
pipeline because it is waiting for audio data, you need to keep the 
audio data going if you want it to be unblocked.  The muxer is too smart 
to assume no data is silence.


On 8/9/2017 7:44 AM, stic at free.fr wrote:
> Hello everyone,
> I have a simple pipeline running with an audio source and video source, muxed together into a tcpserversink.
> The problem I have is that the pipeline freeze once the audio source is ended, but I would like it to continue even is there is no audio anymore in the pipeline.
> What should I do in such case ?
> I tried to drop the EOS signal arriving on the src pad of the audio source bin but it doesn't seem to change anything.
> Could someone describe what should be done in such case ?
> That would really help me, thank you very much in advance !
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org

More information about the gstreamer-devel mailing list