translating command to code for playing an avi
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.
> 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.
>> 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>
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
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),
// the demuxer "pad-added" callback
void on_demuxer_pad_added (GstElement *demuxer, GstPad *pad, GstElement
char* pad_name = gst_pad_get_name(pad);
GstElement* decvd = gst_bin_get_by_name(GST_BIN(pipeline), "decvd");
GstPad *padV = gst_element_get_static_pad(decvd,"sink");
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");
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gstreamer-devel