demux/remux pipeline hangs when audio is added

Carah Smith carah29ingress at gmail.com
Wed Oct 2 14:16:13 PDT 2013


I got it working in the code now. Thank you both for your help! Below is
the working code in case anyone is curious or still struggling with this
issue. All error checking has been removed for conciseness. I didn't
include the helper functions or structure because they did not change all
that much.

int
main(int argc, char **argv)
{
    GstElement *source;
    GstElement *pipeline;
    GstElement *sink;
    GstElement *mux;
    GstElement *x264_enc;
    GstElement *a_convert;
    GstElement *v_convert;
    GstElement *aac_enc;
    struct custom_data data;
    GstElement *v_queue;
    GstElement *a_queue;
    GstBus     *bus;
    GstMessage *msg;
    gboolean terminate = FALSE;

    gst_init (&argc, &argv);

    source    = gst_element_factory_make("uridecodebin", "URI_decoder");
    v_convert = gst_element_factory_make("videoconvert", "video_converter");
    v_queue   = gst_element_factory_make("queue", "v_queue");
    a_queue   = gst_element_factory_make("queue", "a_queue");
    x264_enc  = gst_element_factory_make("x264enc", "h264_encoder");
    a_convert = gst_element_factory_make("audioconvert", "audio_converter");
    aac_enc   = gst_element_factory_make("faac", "aac_encoder");
    mux       = gst_element_factory_make("mpegtsmux", "muxer");
    sink      = gst_element_factory_make("hlssink", "hls_sink");

    data.video = v_queue;
    data.audio = a_queue;

    pipeline = gst_pipeline_new("test-pipeline");

    g_object_set(G_OBJECT(source), "uri", "file:///stream_1.ts", NULL);

    gst_bin_add_many(GST_BIN(pipeline),
                     source, v_queue, a_queue, x264_enc,
                     v_convert, aac_enc, a_convert, mux, sink,
                     NULL);

    gst_element_link_many(a_queue, a_convert, aac_enc, NULL);
    gst_element_link_many(v_queue, v_convert, x264_enc, NULL);
    gst_element_link(mux, sink);

    link_to_multiplexer(x264_enc, mux);
    link_to_multiplexer(aac_enc, mux);

    g_signal_connect(source, "pad-added", G_CALLBACK(on_pad_added), &data);

    gst_element_set_state(pipeline, GST_STATE_PLAYING);

    bus = gst_element_get_bus(pipeline);
    do
    {
        msg = gst_bus_timed_pop(bus, 0);

        if (msg != NULL)
        {
            switch (GST_MESSAGE_TYPE(msg))
            {
                case GST_MESSAGE_ERROR:
                    terminate = TRUE;
                    break;
                case GST_MESSAGE_EOS:
                    g_print("End-Of-Stream reached.\n");
                    terminate = TRUE;
                    break;
                case GST_MESSAGE_STATE_CHANGED:
                    if (GST_MESSAGE_SRC(msg) == GST_OBJECT(pipeline))
                    {
                        GstState old_state, new_state, pending_state;

                        gst_message_parse_state_changed(msg, &old_state,
&new_state, &pending_state);
                        g_print("Pipeline state changed from %s to %s:\n",
                        gst_element_state_get_name(old_state),
gst_element_state_get_name(new_state));
                    }
                    break;
                default:
                break;
            }
            gst_message_unref(msg);
        }
    } while (!terminate);

    gst_object_unref(bus);
    gst_element_set_state(pipeline, GST_STATE_NULL);
    gst_object_unref(pipeline);

    return 0;
}


On Wed, Oct 2, 2013 at 2:50 PM, Carah Smith <carah29ingress at gmail.com>wrote:

> Ok, this worked for me as well. I am going to try and put this exactly
> into my code.
>
>
> On Wed, Oct 2, 2013 at 2:41 PM, Robert Krakora <
> rob.krakora at messagenetsystems.com> wrote:
>
>> This works...xviddec and xvidenc are not ported to GStreamer 1.0...
>>
>> DevKrakora MessageNet # gst-launch-1.0 uridecodebin
>> uri=file:///home/silentm/MessageNet/bbb24p_00.ts name=bin ! queue !
>> videoconvert ! x264enc ! mpegtsmux name=mux ! hlssink bin. ! queue !
>> audioconvert ! faac ! mux.
>>  Setting pipeline to PAUSED ...
>> Pipeline is PREROLLING ...
>> Redistribute latency...
>> Redistribute latency...
>> Pipeline is PREROLLED ...
>> Setting pipeline to PLAYING ...
>> New clock: GstSystemClock
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131002/940fdaa1/attachment-0001.html>


More information about the gstreamer-devel mailing list