<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Thanks, this solved my issue! <br></div><div>The video I'm getting from ximagesrc is not 640x480 but it is the actual size of that window. My problem was solved when I linked the videoscale and nvh264enc element with a filter (instead of putting the filter between videoconvert and videoscale elmenets) . So I changed the relevant part of the code as follows:<br></div><div><br></div><div>    if ((gst_element_link (source, converter) && <b>gst_element_link</b>(converter, scaler)<br></div><div>                                              && <b>link_elements_with_filter</b> (scaler, encoder)<br></div><div>                                              && gst_element_link (encoder, payloader)<br></div><div>                                              && gst_element_link (payloader, sink)) != TRUE) {<br></div><div>        g_printerr ("Elements could not be linked.\n");<br></div><div>        gst_object_unref (pipeline);<br></div><div>        return -1;<br></div><div>    }<br></div><div><br></div><div><br></div><div>-- <br></div><div>  Serhan Gül<br></div><div>  serhan@fastmail.com<br></div><div><br></div><div>On Mon, Jul 15, 2019, at 1:06 PM, Josh Doe wrote:<br></div><div>> On Mon, Jul 15, 2019 at 5:31 AM Serhan Gül <serhan@fastmail.com> wrote:<br></div><div>> ><br></div><div>> > 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.<br></div><div>> ><br></div><div>> > 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.<br></div><div>> ><br></div><div>> > My code looks as follows:<br></div><div>> ><br></div><div>> > static gboolean<br></div><div>> > link_elements_with_filter (GstElement *element1, GstElement *element2)<br></div><div>> > {<br></div><div>> >   gboolean link_ok;<br></div><div>> >   GstCaps *caps;<br></div><div>> ><br></div><div>> >   caps = gst_caps_from_string("video/x-raw,width=640,height=480,framerate=20/1");<br></div><div>> ><br></div><div>> >   link_ok = gst_element_link_filtered (element1, element2, caps);<br></div><div>> >   gst_caps_unref (caps);<br></div><div>> ><br></div><div>> >   if (!link_ok) {<br></div><div>> >       g_warning ("Failed to link element1 and element2!");<br></div><div>> >     }<br></div><div>> ><br></div><div>> >   return link_ok;<br></div><div>> > }<br></div><div>> ><br></div><div>> ><br></div><div>> > int main(int argc, char *argv[]) {<br></div><div>> ><br></div><div>> > (...)<br></div><div>> ><br></div><div>> >  /* Create the elements */<br></div><div>> >   source = gst_element_factory_make ("ximagesrc", "source");<br></div><div>> >   converter = gst_element_factory_make ("videoconvert", "converter");<br></div><div>> >   scaler = gst_element_factory_make ("videoscale", "scaler");<br></div><div>> >   encoder = gst_element_factory_make("nvh264enc", "encoder");<br></div><div>> >   payloader = gst_element_factory_make("rtph264pay", "payloader");<br></div><div>> >   sink = gst_element_factory_make ("udpsink", "sink");<br></div><div>> ><br></div><div>> >   g_object_set (source, "use-damage", FALSE, "xid", 0x5c0000c, NULL);<br></div><div>> >   g_object_set (encoder, "gop-size", 25, "rc-mode", 2, "bitrate", 2000, NULL);<br></div><div>> >   g_object_set (payloader, "config-interval", 1, NULL);<br></div><div>> >   g_object_set (sink, "host", "172.17.25.248", "port", 5004, NULL);<br></div><div>> >   pipeline = gst_pipeline_new ("test-pipeline");<br></div><div>> ><br></div><div>> >   if (!pipeline || !source || !converter || !encoder || !payloader || !sink) {<br></div><div>> >       g_printerr ("Not all elements could be created.\n");<br></div><div>> >       return -1;<br></div><div>> >   }<br></div><div>> ><br></div><div>> ><br></div><div>> >    gst_bin_add_many (GST_BIN (pipeline), source, converter, scaler, encoder, payloader, sink,   NULL);<br></div><div>> >    if ((gst_element_link (source, converter) && link_elements_with_filter(converter, scaler)<br></div><div>> >                                           && gst_element_link (converter, encoder)<br></div><div>> >                                           && gst_element_link (encoder, payloader)<br></div><div>> >                                           && gst_element_link (payloader, sink)) != TRUE) {<br></div><div>> >     g_printerr ("Elements could not be linked.\n");<br></div><div>> >     gst_object_unref (pipeline);<br></div><div>> >     return -1;<br></div><div>> > }<br></div><div>> ><br></div><div>> > (...)<br></div><div>> ><br></div><div>> > When I run this code,  I get the following:<br></div><div>> > ** (gst_server:55698): WARNING **: 11:21:57.315: Failed to link element1 and element2!<br></div><div>> > Elements could not be linked.<br></div><div>> > Process finished with exit code 255<br></div><div>> ><br></div><div>> > 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?<br></div><div>> > Thanks.<br></div><div>> <br></div><div>> If the video from ximagesrc isn't already 640x480, then this will<br></div><div>> fail. You need to filter the caps after videoscale if you want to<br></div><div>> scale it to 640x480.<br></div><div>> _______________________________________________<br></div><div>> gstreamer-devel mailing list<br></div><div>> gstreamer-devel@lists.freedesktop.org<br></div><div>> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel<br></div></body></html>