Gstreamer C/C++ program that creates a pipeline

Nicolas Dufresne nicolas at ndufresne.ca
Thu Aug 26 21:01:02 UTC 2021


Le jeudi 26 août 2021 à 15:22 -0400, Floyd Brown via gstreamer-devel a écrit :
> I have a program that works. It receives a video stream to a vpudec (from
> rtsp), and then we pull a frame off using "glfilterbin" and "glbox". The
> problem is that it keeps the aspect ratio (300x168 from 4K) but it seems the
> powers-at-be would like it simply scaled to 300x300, so no aspect ratio.
> 
> Snippet:
> ...
>  GstElement *filter_ele = add_element("glfilterbin");
>  GstElement *box_ele = gst_element_factory_make("glbox", NULL);
>  g_object_set(filter_ele, "filter", box_ele, NULL);
>  gst_element_link(dec_ele, filter_ele);
> 
>  appsink_ele_ = add_element("appsink");
>  g_object_set(appsink_ele_, "emit-signals", TRUE, NULL);
>  g_signal_connect(appsink_ele_, "new-sample", G_CALLBACK(on_sample_handler),
> this);
>  target_width_ = w;
>  target_height_ = h;
> 
>  std::ostringstream oss;
>  oss << "video/x-raw, format=RGB, width=" << w << ", height=" << h;
>  GstCaps *caps = gst_caps_from_string(oss.str().c_str());
>  g_object_set(appsink_ele_, "caps", caps, NULL);
>  gst_caps_unref(caps);
>  gst_element_link(filter_ele, appsink_ele_);
> ...
> 
> Is there a replacement for glfilterbin and/or glbox that can just scale the
> video to 300x300?

You can scale from 4K to 300x300 (ignoring aspect ratio with a similar pipeline
to:

gst-launch-1.0 gltestsrc ! video/x-raw\(ANY\),width=3840,height=2160 \
  ! glcolorscale \
  ! video/x-raw\(ANY\),width=300,height=300,pixel-aspect-ratio=1/1 \
  ! glimagesink

The trick is to force the aspect ratio, so that glcolorscale is forced to break
the original aspect ratio.

> 
> Thanks
> 
> Floyd Brown
> 




More information about the gstreamer-devel mailing list