Good example to show usage of tee

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Good example to show usage of tee

Baby Octopus
Administrator
Hi,

I'm a gstreamer newbie. I'm writing my own application where in I read from a 1920x1080 YUV file, resize it into different dimensions namely 1280x720, 800x480 and 640x360 and then encode each of these resolutions. I want to connect "filesrc" to 3 different resizer element. I know this is possible using a tee element. However, I have not been able to find a good example which demonstrates one such usage. Please throw some light on this

Regards,
Baby Octopus
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Atish Nazir
Here's an example:

gst-launch filesrc location=source.file ! tee name=tp \
tp. ! queue ! filesink location=destination1.file \
tp. ! queue ! filesink location=destination2.file

The queues are to prevent deadlocking.


On 7 November 2012 14:01, Baby Octopus <[hidden email]> wrote:
Hi,

I'm a gstreamer newbie. I'm writing my own application where in I read from
a 1920x1080 YUV file, resize it into different dimensions namely 1280x720,
800x480 and 640x360 and then encode each of these resolutions. I want to
connect "filesrc" to 3 different resizer element. I know this is possible
using a tee element. However, I have not been able to find a good example
which demonstrates one such usage. Please throw some light on this

Regards,
Baby Octopus



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Good-example-to-show-usage-of-tee-tp4656821.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Tim-Philipp Müller-2
In reply to this post by Baby Octopus
On Wed, 2012-11-07 at 06:01 -0800, Baby Octopus wrote:

> I'm a gstreamer newbie. I'm writing my own application where in I read from
> a 1920x1080 YUV file, resize it into different dimensions namely 1280x720,
> 800x480 and 640x360 and then encode each of these resolutions. I want to
> connect "filesrc" to 3 different resizer element. I know this is possible
> using a tee element. However, I have not been able to find a good example
> which demonstrates one such usage. Please throw some light on this


gst-launch-1.0 v4l2src ! tee name=t \
    t. ! queue ! videoscale ! video/x-raw,width=640,height=480 ! \
            videoconvert ! autovideosink
    t. ! queue ! videoscale ! video/x-raw,width=360,height=240 ! \
            videoconvert ! autovideosink -v


(if you're still on 0.10, replace videoconvert with ffmpegcolorspace and
gst-launch-1.0 with gst-launch-0.10).

The same should work with different inputs as well of course, and you
can add more t. ! queue ! ...  branches.

 Cheers
  -Tim

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Baby Octopus
Administrator
In reply to this post by Atish Nazir
Thank you Atish. But I'm not using gst-launch. I'm developing my own application usging gstreamer APIs. Would have been good if there was some demo which shows how to do this in source code
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Atish Nazir
I find gst_parse_launch useful for quick prototyping tasks:

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstParse.html

Alternatively you'll need to look up the tutorials on creating pipelines, connecting elements and the such like.

On 7 November 2012 15:31, Baby Octopus <[hidden email]> wrote:
Thank you Atish. But I'm not using gst-launch. I'm developing my own
application usging gstreamer APIs. Would have been good if there was some
demo which shows how to do this in source code



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Good-example-to-show-usage-of-tee-tp4656821p4656825.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Baby Octopus
Administrator
Hi Atish,

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) ?

Regards,
Baby Octopus
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Nathanael D. Noblet
On 11/09/2012 12:44 AM, Baby Octopus wrote:
> Hi Atish,
>
> 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...

--
Nathanael d. Noblet
t 403.875.4613
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Baby Octopus
Administrator
Hi Nathanael,

I agree that for complicated pipeline handling is difficult but not impossible. All I want to know is that if there is something which I will not be able to do using command line options

Regards,
BO
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Remco Treffkorn
On Saturday, November 10, 2012 05:10:30 Baby Octopus wrote:
> Hi Nathanael,
>
> I agree that for complicated pipeline handling is difficult but not
> impossible. All I want to know is that if there is something which I will
> not be able to do using command line options
>

Play video full screen.

--
Remco Treffkorn (RT445)
HAM DC2XT
[hidden email]   (831) 685-1201


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

William Manley
In reply to this post by Nathanael D. Noblet
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.

This has been a curiosity of mine for a while, what is the reason that
the examples don't use parse_launch more often.  For example, Christian
Schaller's recent blog post "GStreamer, Python and videomixing"[1]
"manually" constructs a Gstreamer pipeline over several lines.  This
compares to this parse_launch equivalent:

gst.parse_launch('v4l2src ! video/x-raw,width=320,height=240 !
videoconvert ! textoverlay ! videobox border-alpha=0 top=0 left=-320 !
mixer.'
                  'v4l2src ! video/x-raw,width=320,height=240 !
theoraenc ! rtptheorapay ! rtptheoradepay ! theoradec ! videoconvert !
mixer.'
                  'videomixer name=mixer ! videoconvert ! xvimagesink')

Christian clearly knows far more about gstreamer and has more experience
than I do so I'm left wondering what it is that I've missed that means
that those many lines would be preferable to the above.

Anyone?

[1]:
http://blogs.gnome.org/uraeus/2012/11/08/gstreamer-python-and-videomixing/


This transmission contains information that may be confidential and contain personal views which are not necessarily those of YouView TV Ltd. YouView TV Ltd (Co No:7308805) is a limited liability company registered in England and Wales with its registered address at YouView TV Ltd, 3rd Floor, 10 Lower Thames Street, London, EC3R 6YT. For details see our web site at http://www.youview.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Nathanael D. Noblet
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? Also what happens if there are
multiple of the same type of element, how will your code know which one
you are looking for?

--
Nathanael d. Noblet
t 403.875.4613
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Krzysztof Konopko
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.

Cheers,
Kris
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Nathanael D. Noblet
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? 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.

--
Nathanael d. Noblet
t 403.875.4613
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

Krzysztof Konopko
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
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Good example to show usage of tee

David Röthlisberger
In reply to this post by William Manley
On 12 Nov 2012, at 16:30, William Manley wrote:
> This has been a curiosity of mine for a while, what is the reason that
> the examples don't use parse_launch more often.

The "GStreamer SDK" tutorials, at least, seem to recommend using
"gst_parse_launch"[1]:

    Please note that gst-launch is primarily a debugging tool for
    developers. You should not build applications on top of it. Instead,
    use the gst_parse_launch() function of the GStreamer API as an easy
    way to construct pipelines from pipeline descriptions.

...although they introduce it rather late (in the 10th tutorial, after
using gst_element_factory_make etc in all the previous tutorials).
Subsequent tutorials ([2], [3]) do use "gst_parse_launch".

[1] http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+10%3A+GStreamer+tools
[2] http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+12%3A+Streaming
[3] http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+13%3A+Playback+speed

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel