Using caps on videoscale element in the C API

Serhan Gül serhan at fastmail.com
Mon Jul 15 09:52:24 UTC 2019


Sorry, there is an error, the following part should be corrected as:

`   if ((gst_element_link (source, converter) && link_elements_with_filter(converter, scaler)
                                          && gst_element_link (*scaler*, encoder)
                                          && gst_element_link (encoder, payloader)
                                          && gst_element_link (payloader, sink)) != TRUE) {`

I still get the same error though.

On Mon, Jul 15, 2019, at 11:31 AM, Serhan Gül wrote:
> I'm trying to grab video from a window using ximagesrc and scale it to a certain size before encoding in H.264 and streaming with RTP to another machine. I implemented my pipeline in the C API and it works fine unless I add a videoscale element with capsfilter. 
> 
> Specifically, I have a problem understanding how to use the videoscale element correctly and how to link it with a videoconvert element programmatically. The function 'gst_element_link_filtered' returns false when I try to connect the videoconvert and videoscale element using a capsfilter for scaling to the resolution I want. 
> 
> My code looks as follows:
> 
> *static *gboolean
> link_elements_with_filter (GstElement *element1, GstElement *element2)
> {
>   gboolean link_ok;
>   GstCaps *caps;
> 
>   caps = gst_caps_from_string(*"video/x-raw,width=640,height=480,framerate=20/1"*);
> 
>   link_ok = gst_element_link_filtered (element1, element2, caps);
>   gst_caps_unref (caps);
> 
>   *if *(!link_ok) {
>       *g_warning *(*"Failed to link element1 and element2!"*);
>     }
> 
>   *return *link_ok;
> }
> 
> *int *main(*int *argc, *char **argv[]) {
> (...)
> 
>  */* Create the elements */
**  *source = gst_element_factory_make (*"ximagesrc"*, *"source"*);
>   converter = gst_element_factory_make (*"videoconvert"*, *"converter"*);
>   scaler = gst_element_factory_make (*"videoscale"*, *"scaler"*);
>   encoder = gst_element_factory_make(*"nvh264enc"*, *"encoder"*);
>   payloader = gst_element_factory_make(*"rtph264pay"*, *"payloader"*);
>   sink = gst_element_factory_make (*"udpsink"*, *"sink"*);
> *
  *g_object_set (source, *"use-damage"*, FALSE, *"xid"*, 0x5c0000c, NULL);
> *  *g_object_set (encoder, *"gop-size"*, 25, *"rc-mode"*, 2, *"bitrate"*, 2000, NULL);
> *  *g_object_set (payloader, *"config-interval"*, 1, NULL); *
>   *g_object_set (sink, *"host"*, *"172.17.25.248"*, *"port"*, 5004, NULL);
> *
  *pipeline = gst_pipeline_new (*"test-pipeline"*);
> 
>   *if *(!pipeline || !source || !converter || !encoder || !payloader || !sink) {
>       g_printerr (*"Not all elements could be created.**\n**"*);
>       *return *-1;
>   }
> 
>    gst_bin_add_many (GST_BIN (pipeline), source, converter, scaler, encoder, payloader, sink,   NULL);
> *   if *((gst_element_link (source, converter) && link_elements_with_filter(converter, scaler)
>                                           && gst_element_link (converter, encoder)
>                                           && gst_element_link (encoder, payloader)
>                                           && gst_element_link (payloader, sink)) != TRUE) {
>     g_printerr (*"Elements could not be linked.**\n**"*);
>     gst_object_unref (pipeline);
>     *return *-1;
> }
> 
> (...)
> 
> When I run this code, I get the following:
> ** (gst_server:55698): WARNING **: 11:21:57.315: Failed to link element1 and element2!
> Elements could not be linked.
> Process finished with exit code 255
> 
> So I have problems connecting the videoconvert and videoscale elements. Is there something wrong with the order of the elements in the pipeline, or perhaps with my usage of caps? 
> Thanks.
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190715/58b07f0c/attachment.html>


More information about the gstreamer-devel mailing list