@@ -616,13 +616,23 @@ namespace gstreamer {
616616 for (const auto & gstreamer_def : gstreamer::getGStreamerDefinition (gopts)) {
617617 auto gstreamer_def_thread = GStreamerDefinition (gstreamer_def, thread_id);
618618 std::string gstreamer_plugin = gstreamer_def_thread.gstreamerPluginName ();
619+ // Key the map by the unique per-output rootname so that multiple same-format
620+ // outputs (e.g. two csv files) do not collide; the plugin library is still
621+ // loaded by the format-derived plugin name.
622+ const std::string& output_key = gstreamer_def_thread.rootname ;
619623
620- // Load the plugin object for this configured output.
624+ // Load the plugin object for this configured output. Each call returns a
625+ // fresh GStreamer instance, so same-format outputs stay independent.
621626 auto streamer = manager.LoadAndRegisterObjectFromLibrary <GStreamer>(gstreamer_plugin, gopts);
622- gstreamers->emplace (gstreamer_plugin, streamer);
623-
624- // Bind the thread-specialized definition to the plugin instance.
625- gstreamers->at (gstreamer_plugin)->define_gstreamer (gstreamer_def_thread);
627+ auto [it, inserted] = gstreamers->emplace (output_key, streamer);
628+ if (!inserted) {
629+ log->warning (" duplicate gstreamer output name '" , output_key,
630+ " ' - ignoring later definition" );
631+ continue ;
632+ }
633+
634+ // Bind the thread-specialized definition to this (freshly created) plugin instance.
635+ it->second ->define_gstreamer (gstreamer_def_thread);
626636 }
627637
628638 return gstreamers;
0 commit comments