Pls help - gtk4paintablesink nightmare

I’m trying to get gtk4paintablesink to work on my macOS Sonoma system. I’m pulling my hair out as this should not be this hard or require some sort of “secret decoder ring” to do this. (someone in a discourse chat suggested this, probably kidding)

gstreamer works as it should and I’ve tested all the basic examples and play tutorials.

I have installed the current version of gstreamer for macOS (apple framework & devel 1.25.90) and have downloaded and installed the rust gtk4 plugin via cargo by building a boilerplate project and then doing a

cargo add gst-plugin-gtk4@=0.13.5

I’ve got my GST_PLUGIN_PATH set to the directory it’s in:

/Users/P/mygstplugin

running

gst-inspect-1.0 gtk4paintablesink

returns:

No such element or plugin ‘gtk4paintablesink’

running

gst-launch-1.0 videotestsrc ! autovideosink

runs as it should.

Can anyone please tell me what I’m doing wrong or is there a doc or recipe and how to successfully build this for macOS?

I realize I could install this via homebrew but can confirm that the rust gtk4 plugins do not install automatically via homebrew and so I would need to build the gtk4 plugin anyway.

Please if anyone can give me some tips I would appreciate it - I really need to try to get past this so I can move forward with my gtk4-based gstreamer project. thank you thank you

If you add the GTK4 plugin as a dependency to your Rust project (i.e. add it to the Cargo.toml), then you statically link to it and will have to first initialize it right after gst::init() like in the example.

If you do that then gst-inspect-1.0 / gst-lauch-1.0 and other GStreamer applications won’t find the plugin: it’s statically linked into your application and only visible to your application.

The alternative is to build the plugin as a shared library and putting it into the any of the GStreamer plugin paths. For that follow the instructions in the README. You can also use cargo directly instead of cargo-c, the differences are minimal (other than cargo not being able to install things so you have to copy yourself).


In your case you did the first approach, but instead of adding it to your project you added the plugin as a dependency to a dummy cargo project. That way the built plugin is not visible to anything but that dummy cargo project, which is not very useful.

Also you might want to join the GStreamer matrix space. There’s also a room specifically for GStreamer/Rust related topics.

thank you for your suggestions, but they don’t help because I didn’t explain clearly:

I have several successfully running GStreamer C programs. I want to use the GTK4 gstreamer plugin to add some UI, etc.

All I want to do is download the GTK4 rust plugin so I can use it. That’s all. I don’t use cargo or rust but am trying to learn so I can do this. All my programs are in C. I’m using the current version of GStreamer macOS binaries. GStreamer works well, as do my C programs that use it.

Through homebrew I have gtk3 and gtk4 installed and they work as they should. I also have rust and cargo installed and cargo-c.

It’s my understanding that on macOS I need to install the gst-plugins-rs to get the gtk4 plugin, specifically the:

gtk4 : A GTK4 video sink that provides a GdkPaintable for UI integration.

I need help making sure I have everything correctly in place to install the plugin.

Questions:

– do I need to build a “cargo project” to do the build? Someone suggested that so I built a “dummy project”, tested it for “hello world” and it works so I added the rs plugins to it by doing this:

cargo add gst-plugin-gtk4@=0.13.5

that updated the crates.io index and added gst-plugin-gtk4 = 0.13.5 to dependencies and listed all the features

– is this correct? If yes, what do I need to do next?

crate cbuild -p gst-plugin-gtk4 ??

should I build it where the other gstreamer binaries are installed on my system here:?

/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/gstreamer-1.0

This is where I’m stuck. Can someone please help get me past this issue? I have a friend who has been helping but he is running linux and the rust plugins are there with his current version of GStreamer and he can do a gst-insptect-1.0 for gtk4paintablesink and it’s there.

Thanks for any help.

No, that’s completely wrong for every possible scenario.

Follow the instructions from the README in the gst-plugins-rs repository. You use cargo cbuild for building, cargo cinstall for installing.

By default this should install in the correct location based on the GStreamer pkg-config file it finds during the build. If not you need to provide the location.

That’s where the GStreamer binaries expect them to be, yes. You can’t mix GStreamer from the binaries and homebrew GTK (or anything else using GLib) though. You’ll have to decide on one.

@slomo thank you so much for your help. I was able to get the plugin to build and install. You really helped me thank you.

For the benefit of others I’m including the steps I used:

  • based on @slomo’s suggestion I decided to only use versions of gstreamer and gtk4 that are installed via homebrew. To do this I removed all path and export references from my .bash_profile to the Apple Frameworks version of gstreamer. Then I:

— installed gstreamer via homebrew which installed 1.26.0

— changed .bash_profile to reflect and point to brew versions of gstreamer, gtk4, etc and sourced it to terminal windows I’m working in

— updated GST_PLUGIN_PATH to reflect the a directory I created for the plugin, in my case on macOS I put it here:

/opt/homebrew/Cellar/gstreamer/gtk4plugin

— downloaded the gst-plugins-rs from gitlab (downloaded a zip into a working directory)

— from that dir I did the following:

cargo cbuild -p gst-plugin-gtk4

— then I did:

cargo cinstall -p gst-plugin-gtk4 —libdir=/opt/homebrew/Cellar/gstreamer/gtk4plugin

it installed the plugin there — the system confirms it when I do this:

gst-inspect-1.0 gtk4paintablesink

I hope this also helps someone. Thanks again

1 Like