Search code examples
rustgstreamer

How to specify caps for Gstreamer in Rust?


When I do:

gst-launch-1.0 v4l2src ! videoconvert ! waylandink

I get a video stream and from gst-device-monitor-1.0 I can say it's video/x-raw

When I do:

gst-launch-1.0 v4l2src ! video/x-h264 ! avdec_h264 ! videoconvert ! waylandink

I get the encoded stream instead of the raw one.

My question is: how can I specify the caps video/x-h264 for my source element in Rust? I can use the set-property method to change the width, height, or framerate but I can't find how to change from raw to h264


Solution

  • The syntax

    ! caps !
    

    in gst-launch automatically creates a capsfilter element.

    In your Rust code, you would create the capsfilter element explicitly.