<meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Hi,  <div><br></div><div>I&#39;ve built a small pipeline..</div>
<div><br></div><div>                                                                                                 - queue2 ! filesrc (file1.avi)</div><div>v4l2src ! {caps filter } ! ffmpegcolorspace ! jpegenc ! avimux ! tee ! -| <br clear="all">
<div>                                                                                                 - queue2 ! filesrc (file2.avi)</div><div><br></div><div><br></div><div>Works great!  I get identical copies of my web cam recorded to two files.</div>
<div><br></div><div><br></div><div><br>But, what I really need is to replace &quot;tee&quot; with &quot;output selector&quot;</div><div><br></div><div>Like this</div><div><div>                                                                                                 - queue2 ! filesrc (file1.avi)</div>
<div><br></div><div>v4l2src ! {caps filter } ! ffmpegcolorspace ! jpegenc ! avimux ! output-selector ! -|</div><div> <br clear="all"><div>                                                                                                 - queue2 ! filesrc (file2.avi)</div>
<div><br></div></div></div><div>I also added     </div><div><br></div><div><div>GstPad* pad = gst_element_get_pad( selector, &quot;sink&quot; );</div></div><div>g_object_set(G_OBJECT(selector), &quot;active-pad&quot;, pad, NULL);</div>
<div><br></div><div><br></div><div>However when I change to the output-selector I get no errors and no output at all to the two files.</div><div><br></div><div><br></div><div>Anyone know what I&#39;m missing?  Can anyone suggest a good source for sample code demonstrating how to wire up an output-selector element?</div>
<div><br></div><div>complete code below... it is directly derivative if the hello world app.</div><div><br></div><div>Thanks,</div><div><br></div><div><br></div><div>Garth Tissington</div><div><br></div><div><br></div><div>
Complete code </div><div><br></div><div><br></div><div>=========================</div><div><br></div><div><div>#include &lt;gst/gst.h&gt;</div><div>#include &lt;glib.h&gt;</div><div>#include &lt;gstreamer-0.10/gst/gstelementfactory.h&gt;</div>
<div><br></div><div>static gboolean</div><div>bus_call(GstBus *bus,</div><div>        GstMessage *msg,</div><div>        gpointer data) {</div><div>    GMainLoop *loop = (GMainLoop *) data;</div><div><br></div><div>    switch (GST_MESSAGE_TYPE(msg)) {</div>
<div><br></div><div>        case GST_MESSAGE_EOS:</div><div>            g_print(&quot;End of stream\n&quot;);</div><div>            g_main_loop_quit(loop);</div><div>            break;</div><div><br></div><div>        case GST_MESSAGE_ERROR:</div>
<div>        {</div><div>            gchar *debug;</div><div>            GError *error;</div><div><br></div><div>            gst_message_parse_error(msg, &amp;error, &amp;debug);</div><div>            g_free(debug);</div>
<div><br></div><div>            g_printerr(&quot;Error: %s\n&quot;, error-&gt;message);</div><div>            g_error_free(error);</div><div><br></div><div>            g_main_loop_quit(loop);</div><div>            break;</div>
<div>        }</div><div>        default:</div><div>            break;</div><div>    }</div><div><br></div><div>    return TRUE;</div><div>}</div><div><br></div><div>static void</div><div>on_pad_added(GstElement *element,</div>
<div>        GstPad *pad,</div><div>        gpointer data) {</div><div>    GstPad *sinkpad;</div><div>    GstElement *decoder = (GstElement *) data;</div><div><br></div><div>    /* We can now link this pad with the vorbis-decoder sink pad */</div>
<div>    g_print(&quot;Dynamic pad created, linking demuxer/decoder\n&quot;);</div><div><br></div><div>    sinkpad = gst_element_get_static_pad(decoder, &quot;sink&quot;);</div><div><br></div><div>    gst_pad_link(pad, sinkpad);</div>
<div><br></div><div>    gst_object_unref(sinkpad);</div><div>}</div><div><br></div><div>GstElement* CreateDvrBin() {</div><div>    GstElement *pipeline, *source, *colorspace, *muxer, *encoder, *selector, *sink1, *sink2, *q1, *q2 ;</div>
<div><br></div><div>    source = gst_element_factory_make(&quot;v4l2src&quot;, &quot;source&quot;);</div><div>    muxer = gst_element_factory_make(&quot;avimux&quot;, &quot;muxer&quot;);</div><div>    encoder = gst_element_factory_make(&quot;jpegenc&quot;, &quot;encoder&quot;);</div>
<div>    colorspace = gst_element_factory_make(&quot;ffmpegcolorspace&quot;, &quot;colorspace&quot;);</div><div>    q1 = gst_element_factory_make(&quot;queue2&quot;, &quot;q1&quot;);</div><div>    q2 = gst_element_factory_make(&quot;queue2&quot;, &quot;q2&quot;);</div>
<div>    sink1 = gst_element_factory_make(&quot;filesink&quot;, &quot;sink1&quot;);</div><div>    sink2 = gst_element_factory_make(&quot;filesink&quot;, &quot;sink2&quot;);</div><div>    selector = gst_element_factory_make(&quot;output-selector&quot;, &quot;selector&quot;);</div>
<div><br></div><div>    if (!pipeline || !source || !colorspace || !encoder || !muxer || !sink1 || !sink2 || !selector || !q1 || !q2 ) {</div><div>        g_printerr(&quot;One element could not be created. Exiting.\n&quot;);</div>
<div>        return NULL;</div><div>    }</div><div><br></div><div>    /* Set up the pipeline */</div><div>    pipeline = gst_pipeline_new(&quot;DVR&quot;);</div><div><br></div><div>    g_object_set(G_OBJECT(sink1), &quot;location&quot;, &quot;/home/garth/a1.avi&quot;, NULL);</div>
<div>    g_object_set(G_OBJECT(sink2), &quot;location&quot;, &quot;/home/garth/a2.avi&quot;, NULL);</div><div><br></div><div><br></div><div>    /* we add all elements into the pipeline */</div><div>    /* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */</div>
<div>    GstCaps *caps;</div><div><br></div><div>    caps = gst_caps_new_simple(&quot;video/x-raw-yuv&quot;,</div><div>            //   &quot;format&quot;, GST_TYPE_FOURCC, GST_MAKE_FOURCC (&#39;I&#39;, &#39;4&#39;, &#39;2&#39;, &#39;0&#39;),</div>
<div>            &quot;width&quot;, G_TYPE_INT, 800,</div><div>            &quot;height&quot;, G_TYPE_INT, 600,</div><div>            &quot;framerate&quot;, GST_TYPE_FRACTION, 30, 1,</div><div>            NULL);</div><div>
<br></div><div>    gst_bin_add_many(GST_BIN(pipeline),</div><div>            source, colorspace, encoder, muxer, selector, q1, q2, sink1, sink2, NULL);</div><div><br></div><div><br></div><div>    gst_element_link_filtered(source, colorspace, caps);</div>
<div>    gst_element_link(colorspace, encoder);</div><div>    gst_element_link(encoder, muxer);</div><div><br></div><div><br></div><div>    gst_element_link(muxer, selector);</div><div><br></div><div><br></div><div>    GstPad* pad1 = gst_element_get_request_pad(selector, &quot;src%d&quot;);</div>
<div>    gchar *padName1 = gst_pad_get_name(pad1);</div><div>    g_print(&quot;Pad 1: %s\n&quot;, padName1);</div><div>    GstPad* pad2 = gst_element_get_request_pad(selector, &quot;src%d&quot;);</div><div>    gchar *padName2 = gst_pad_get_name(pad2);</div>
<div>    g_print(&quot;Pad 2: %s\n&quot;, padName2);</div><div><br></div><div><br></div><div>    gst_element_link_pads(selector, padName1, q1, &quot;sink&quot;);</div><div>    gst_element_link_pads(selector, padName2, q2, &quot;sink&quot;);</div>
<div><br></div><div>    gst_element_link(q1, sink1);</div><div>    gst_element_link(q2, sink2);</div><div><br></div><div><br></div><div><br></div><div>    return pipeline;</div><div><br></div><div>}</div><div><br></div><div>
//gboolean</div><div>//timeout_cb(gpointer data) {</div><div>//    g_print(&quot;Tick\n&quot;);</div><div>//</div><div>//}</div><div><br></div><div>int</div><div>main(int argc,</div><div>        char *argv[]) {</div><div>
<br></div><div>    //  gint m_timer =</div><div>    //          g_timeout_add(2000, timeout_cb, NULL);</div><div><br></div><div><br></div><div>    GMainLoop *loop;</div><div>    GstBus *bus;</div><div><br></div><div>    GstElement *pipeline;</div>
<div><br></div><div>    /* Initialization */</div><div>    gst_init(&amp;argc, &amp;argv);</div><div><br></div><div>    loop = g_main_loop_new(NULL, FALSE);</div><div><br></div><div>    /* Create gstreamer elements */</div>
<div><br></div><div><br></div><div><br></div><div>    pipeline = CreateDvrBin();</div><div><br></div><div><br></div><div>    /* we add a message handler */</div><div>    // bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));</div>
<div>    // gst_bus_add_watch (bus, bus_call, loop);</div><div>    // gst_object_unref (bus);</div><div><br></div><div><br></div><div><br></div><div>    //g_signal_connect (demuxer, &quot;pad-added&quot;, G_CALLBACK (on_pad_added), decoder);</div>
<div><br></div><div>    /* note that the demuxer will be linked to the decoder dynamically.</div><div>       The reason is that Ogg may contain various streams (for example</div><div>       audio and video). The source pad(s) will be created at run time,</div>
<div>       by the demuxer when it detects the amount and nature of streams.</div><div>       Therefore we connect a callback function which will be executed</div><div>       when the &quot;pad-added&quot; is emitted.*/</div>
<div><br></div><div>    /* Set the pipeline to &quot;playing&quot; state*/</div><div>    g_print(&quot;Now playing: %s\n&quot;, argv[1]);</div><div>    gst_element_set_state(pipeline, GST_STATE_PLAYING);</div><div><br></div>
<div><br></div><div>    /* Iterate */</div><div>    g_print(&quot;Running...\n&quot;);</div><div>    g_main_loop_run(loop);</div><div><br></div><div><br></div><div>    /* Out of the main loop, clean up nicely */</div><div>
    g_print(&quot;Returned, stopping playback\n&quot;);</div><div>    gst_element_set_state(pipeline, GST_STATE_NULL);</div><div><br></div><div>    g_print(&quot;Deleting pipeline\n&quot;);</div><div>    gst_object_unref(GST_OBJECT(pipeline));</div>
<div><br></div><div>    return 0;</div><div>}</div></div></div><div><br></div></span>