Simple Q: How to set Caps programmatically when assembly a pipeline in C

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

Simple Q: How to set Caps programmatically when assembly a pipeline in C

HaroldJRoth
This is a really simple question that for some reason I can't find an answer to in the docs.  This probably means I'm going about it all wrong, but here goes:

I want to convert the following pipeline spec into 'C' code:

gst-launch filesrc location=videotestsrc.ogg ! decodebin2 ! videoscale ! video/x-raw-yuv, width=50 ! queue ! appsrc

E.g. I want to scale the video output coming from decodebin2 to a width and format, then I want to pass it through a queue to my appsrc element.

And I want to do it with the 'C' API.

So, I'm thinking the bit in the middle needs to be something like:

GstElement mVideoScaler = gst_element_factory_make("videoscale", "videoscaler");
GstElement mDecoderOutput = gst_element_factory_make("decodebin2", "decoder");
GstElement mVideoQueue = gst_element_factory_make("queue", "videoqueue");

GstCaps* videoCaps = gst_caps_new_simple ("video/x-raw-yuv",
             "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
             "width", G_TYPE_INT, 50,
             NULL);

gst_bin_add_many(GST_BIN(mGstPipeline), mDecoderOutput, mVideoScaler, mVideoQueue, NULL);
gst_element_link_filtered (mDecoderOutput, mVideoScaler, videoCaps)
gst_element_link_filtered (mVideoScaler, mVideoQueue)


Does this seem sensible?

Reply | Threaded
Open this post in threaded view
|

Re: Simple Q: How to set Caps programmatically when assembly a pipeline in C

Thiago Sousa Santos-2


On Sat, Nov 6, 2010 at 9:23 AM, HaroldJRoth <[hidden email]> wrote:

This is a really simple question that for some reason I can't find an answer
to in the docs.  This probably means I'm going about it all wrong, but here
goes:

I want to convert the following pipeline spec into 'C' code:

gst-launch filesrc location=videotestsrc.ogg ! decodebin2 ! videoscale !
video/x-raw-yuv, width=50 ! queue ! appsrc

E.g. I want to scale the video output coming from decodebin2 to a width and
format, then I want to pass it through a queue to my appsrc element.

And I want to do it with the 'C' API.

So, I'm thinking the bit in the middle needs to be something like:

GstElement mVideoScaler = gst_element_factory_make("videoscale",
"videoscaler");
GstElement mDecoderOutput = gst_element_factory_make("decodebin2",
"decoder");
GstElement mVideoQueue = gst_element_factory_make("queue", "videoqueue");

GstCaps* videoCaps = gst_caps_new_simple ("video/x-raw-yuv",
            "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2',
'0'),
            "width", G_TYPE_INT, 50,
            NULL);

gst_bin_add_many(GST_BIN(mGstPipeline), mDecoderOutput, mVideoScaler,
mVideoQueue, NULL);
gst_element_link_filtered (mDecoderOutput, mVideoScaler, videoCaps)
gst_element_link_filtered (mVideoScaler, mVideoQueue)


Does this seem sensible?

The caps on the middle of your gst-launch line is syntactic sugar. In the pipeline it is converted to a 'capsfilter' element with the 'caps' property set to the caps you provide. Try creating a capsfilter and setting its property with g_object_set.
 


--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Simple-Q-How-to-set-Caps-programmatically-when-assembly-a-pipeline-in-C-tp3029913p3029913.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Thiago Sousa Santos

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Simple Q: How to set Caps programmatically when assembly a pipeline in C

Tim-Philipp Müller-2
In reply to this post by HaroldJRoth
On Sat, 2010-11-06 at 05:23 -0700, HaroldJRoth wrote:

> gst-launch filesrc location=videotestsrc.ogg ! decodebin2 ! videoscale !
> video/x-raw-yuv, width=50 ! queue ! appsrc
>
> E.g. I want to scale the video output coming from decodebin2 to a width and
> format, then I want to pass it through a queue to my appsrc element.
> ...
> GstCaps* videoCaps = gst_caps_new_simple ("video/x-raw-yuv",
>              "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2',
> '0'),
>              "width", G_TYPE_INT, 50,
>              NULL);

FWIW, you may also need to add an ffmpegcolorspace element between
decodebin2 and your caps filter, unless you know for sure that all
decoders you'll ever use will output video in I420 format.

 Cheers
  -Tim



------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Simple Q: How to set Caps programmatically when assembly a pipeline in C

HaroldJRoth
In reply to this post by Thiago Sousa Santos-2
thiagossantos@gmail.com wrote
On Sat, Nov 6, 2010 at 9:23 AM, HaroldJRoth <dlafferty@gmail.com> wrote:
> So, I'm thinking the bit in the middle needs to be something like:
>
> GstElement mVideoScaler = gst_element_factory_make("videoscale",
> "videoscaler");
> GstElement mDecoderOutput = gst_element_factory_make("decodebin2",
> "decoder");
> GstElement mVideoQueue = gst_element_factory_make("queue", "videoqueue");
>
> GstCaps* videoCaps = gst_caps_new_simple ("video/x-raw-yuv",
>             "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2',
> '0'),
>             "width", G_TYPE_INT, 50,
>             NULL);
>
> gst_bin_add_many(GST_BIN(mGstPipeline), mDecoderOutput, mVideoScaler,
> mVideoQueue, NULL);
> gst_element_link_filtered (mDecoderOutput, mVideoScaler, videoCaps)
> gst_element_link_filtered (mVideoScaler, mVideoQueue)
>
>
> Does this seem sensible?
>

The caps on the middle of your gst-launch line is syntactic sugar. In the
pipeline it is converted to a 'capsfilter' element with the 'caps' property
set to the caps you provide. Try creating a capsfilter and setting its
property with g_object_set.

Seems the same as gst_element_link_filtered that I'm using above.  (The first one.  The second use has an obvious typo in that an argument is missing.)

See http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-link-filtered
 
Reply | Threaded
Open this post in threaded view
|

Re: Simple Q: How to set Caps programmatically when assembly a pipeline in C

HaroldJRoth
In reply to this post by Tim-Philipp Müller-2
Tim-Philipp Müller-2 wrote
On Sat, 2010-11-06 at 05:23 -0700, HaroldJRoth wrote:

> gst-launch filesrc location=videotestsrc.ogg ! decodebin2 ! videoscale !
> video/x-raw-yuv, width=50 ! queue ! appsrc
>
> E.g. I want to scale the video output coming from decodebin2 to a width and
> format, then I want to pass it through a queue to my appsrc element.
> ...
> GstCaps* videoCaps = gst_caps_new_simple ("video/x-raw-yuv",
>              "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2',
> '0'),
>              "width", G_TYPE_INT, 50,
>              NULL);

FWIW, you may also need to add an ffmpegcolorspace element between
decodebin2 and your caps filter, unless you know for sure that all
decoders you'll ever use will output video in I420 format.


 Cheers
  -Tim
Thanks for the heads up.  I'll be sure to put one between decoderbin2 and the videoscale.

Apart from that, does it matter that the caps isn't fully specified?  E.g. I've not set the height or framerate.

Also, at link, does the decoderbin2 get forced to create a videopad that meets the downstream caps requirements?