translating command to code for playing an avi

Nicolai Hess nicolaihess at web.de
Tue Jan 3 13:13:24 PST 2012


2012/1/3 Rossana Guerra <guerra.rossana at gmail.com>

> Actually I use the "pad-added" event it was posted in the thread :) but
> for sure, I did it wrong since I get  the "caps are incompatible" message.
> thanks!
>
> 2012/1/3 Nathanael D. Noblet <nathanael at gnat.ca>
>
> On 01/03/2012 11:21 AM, Rossana Guerra wrote:
>>
>>> I need to point out that using the gstparse it works. It fails when I
>>> try to create the pipeline by myself.
>>>
>>
>> Hello,
>>
>>  I haven't read this thread, however it seems that more often than not
>> when going from a gst-launch command to code to create a pipeline the most
>> common mistake is to try linking a decoder to the rest of the pipeline. The
>> issue here is that prior to the decoder getting some data, it doesn't know
>> how many streams it contains (a file could have multiple audio streams for
>> one video for example). So you have to use the 'pad-added' signals to
>> dynamically link things once everything is ready. If you google for the
>> gstreamer hello world example it has an example of doing just that.
>> Hopefully that helps if this is the issue, otherwise feel free to disregard
>> this message...
>>
>> --
>> Nathanael d. Noblet
>> t 403.875.4613
>>
>> ______________________________**_________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.**freedesktop.org<gstreamer-devel at lists.freedesktop.org>
>> http://lists.freedesktop.org/**mailman/listinfo/gstreamer-**devel<http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel>
>>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
Hi Rossana,
I think you need an additional pad-added callback for your avidemux element.
I don't get the "incompatible pad" error message, but instead the
targetsrc and targetsrc2 pads from
GstPad *targetsrc = gst_element_get_pad(demuxer, "video_%02");
GstPad *targetsrc2 = gst_element_get_pad(demuxer, "audio_%02");
are NULL, because the demuxer srcpads are "sometimes" pads and
not available at this point.
So, add another on_pad_added callback and link your
video and audio decodebin there, depending on the type of the pad added.


Something like this:

// register the callback
g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_demuxer_pad_added),
pipeline);

// the  demuxer "pad-added" callback
void on_demuxer_pad_added (GstElement *demuxer, GstPad *pad, GstElement
*pipeline)
{
  char* pad_name = gst_pad_get_name(pad);
  if(g_strrstr(pad_name, "video_00"))
  {
    GstElement* decvd = gst_bin_get_by_name(GST_BIN(pipeline), "decvd");
    GstPad *padV = gst_element_get_static_pad(decvd,"sink");
    gst_pad_link(pad,padV);
    gst_object_unref(decvd);
  }
  else if(g_strrstr(pad_name, "audio_00"))
  {
    GstElement* decad = gst_bin_get_by_name(GST_BIN(pipeline), "decad");
    GstPad *padA = gst_element_get_static_pad(decad,"sink");
    gst_pad_link(pad,padA);
    gst_object_unref(decad);
  }
  g_free(pad_name);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20120103/f7f99a29/attachment.html>


More information about the gstreamer-devel mailing list