Good example to show usage of tee
Krzysztof Konopko
krzysztof.konopko at youview.com
Wed Nov 14 01:52:07 PST 2012
On 13/11/12 21:34, Nathanael D. Noblet wrote:
> On 11/13/2012 10:54 AM, Krzysztof Konopko wrote:
>> On 13/11/12 16:06, Nathanael D. Noblet wrote:
>>> On 11/12/2012 09:30 AM, William Manley wrote:
>>>> On 09/11/12 16:53, Nathanael D. Noblet wrote:
>>>>> On 11/09/2012 12:44 AM, Baby Octopus wrote:
>>>>>> Thanks for your suggestion. I see gst_launch_parse takes in
>>>>>> commandline
>>>>>> string and then creates a pipeline based on this, which actually
>>>>>> simplifies
>>>>>> my task. But all I want to know is, is this the right way to create a
>>>>>> pipeline even when you are creating a product of your own, which you
>>>>>> will
>>>>>> market? Can I create any possible pipeline using gst_parse_launch(or
>>>>>> gst-launch) ?
>>>>>
>>>>> I would expect that you want to manually build the pipes. Often with
>>>>> complex pipes you need to attach to signals/events and doing so
>>>>> requires
>>>>> knowing the element etc.. which is easier if you instantiated it
>>>>> directly than searching through a pipeline for a matching element...
>>>>
>>>> I disagree. With complex pipes I think parse_launch becomes even more
>>>> helpful as it becomes harder to visualise what the pipeline actually
>>>> contains, particularly with teeing and muxing, etc. You can use
>>>> gst_bin_get_by_name to easily retrieve the elements.
>>>
>>> How do you know what the element's named?
>>
>> By setting its 'name' attribute.
>>
>>> Also what happens if there are
>>> multiple of the same type of element, how will your code know which one
>>> you are looking for?
>>>
>>
>> Once you set the 'name' attribute for each of them, you know their
>> names. GStreamer won't let you set the same name for more multiple
>> elements.
>
> So I guess then you would be putting the name into your gst_parse_launch
> string?
Exactly.
>Or are you iterating over all elements in a pipe and giving them
> names? Also when you use bins like encodebin or decodebin getting the
> child seems harder to me, as does setting some of the settings... Just
> my opinion though. I've only been using gstreamer for a year or two.
>
Here's how I do it.
error = NULL;
pipeline =
gst_parse_launch (" videotestsrc name=src"
" ! mpeg2enc name=enc"
" ! mpegtsmux name=mux"
" ! filesink name=sink",
&error);
...
sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
if (!sink) {
g_printerr ("Failed to get sink element by name\n");
return EXIT_FAILURE;
}
g_object_set (G_OBJECT (sink), "location", savefile, NULL);
gst_object_unref (sink);
...
Referring to elements by name is quite handy although I can imagine it's
not ideal in every situation.
Getting objects "by name" is a quite common concept along with "by
index" and "by object/reference" in systems where elements form some
sort of hierarchy (or a graph in general). So it's nothing special about
GStreamer or GLib.
Kris
More information about the gstreamer-devel
mailing list