Skip to content

Conversation

@ferjm
Copy link
Member

@ferjm ferjm commented Nov 25, 2025

We need a way to run multiple Edge Impulse models in the same GStreamer pipeline, but the plugin can only be loaded once per process. This is annoying when you want to compare models or run different configurations side-by-side.

So I added a PLUGIN_VARIANT environment variable that lets you build multiple variants of the plugin. Each one gets unique names for everything: the library file, plugin name, element names, and GObject types. That way they can all coexist without stepping on each other.

The tricky part was that GStreamer derives the plugin registration function name from the library filename, and Cargo doesn't let us change the output library name dynamically. So we generate the plugin definition code in build.rs based on the variant, and then rename the library after build with a simple script. We also generate unique GObject type names to avoid the "type already registered" panic you'd get otherwise.

Usage is pretty straightforward:

# Build a variant
PLUGIN_VARIANT=person-detection cargo build --release
PLUGIN_VARIANT=person-detection ./rename-library.sh

# Then use multiple variants together
gst-launch-1.0 \
  autovideosrc ! \
  videoconvert ! \
  video/x-raw,format=RGB,width=640,height=480 ! \
  edgeimpulsevideoinfer_person-detection ! \
  edgeimpulsevideoinfer_anomaly-detection ! \
  edgeimpulseoverlay_person-detection ! \
  autovideosink

@ferjm ferjm merged commit 0d9ba74 into main Nov 25, 2025
1 check passed
@ferjm ferjm deleted the plugin-variant branch November 25, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants