问题
I try to display RTSP stream using Gstreamer in my WPF application.
So I did so far:
- installed GStreamer into loal folder F:/gstreamer
- Created new WPF application
- Added glib-sharp and gstreamer-sharp as dependencies.
The code below I use to init the library:
Gst.Application.Init(); // (1)
mainLoop = new GLib.MainLoop();
mainGLibThread = new System.Threading.Thread(mainLoop.Run);
mainGLibThread.Start();
Element uriDecodeBin = ElementFactory.Make("playbin", "uriDecodeBin0"); // (2)
Unable to load DLL 'libgstreamer-1.0-0.dll': The specified module could not be found.
on line (1). If I copy all the gstreamer dlls into bin/Debug folder the exception gone but ElementFactory.Make
in line (2) always returns null
without any exception. If I try to do something like
Parse.Launch(@"videotestsrc ! videoconvert ! autovideosink")
to test the library functionality I get error:
no element "videotestsrc"
but if I run it from command line:
gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
that works as expected.
So my question - how to get GStreamer-sharp work?
回答1:
Change path to GStream and add this code before start
string path = @"G:\gstreamer\1.0\x86\"; // path to your gstream
string pluginpath = @"G:\gstreamer\1.0\x86\lib\gstreamer-1.0\"; // path to your gstream
string registry = System.IO.Path.Combine(path, "registry.bin");
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + path);
Environment.SetEnvironmentVariable("GST_PLUGIN_PATH", pluginpath + ";" + Environment.GetEnvironmentVariable("GST_PLUGIN_PATH"));
Environment.SetEnvironmentVariable("GST_PLUGIN_SYSTEM_PATH_1_0", pluginpath + ";" + Environment.GetEnvironmentVariable("GST_PLUGIN_SYSTEM_PATH_1_0"));
Environment.SetEnvironmentVariable("GST_PLUGIN_SYSTEM_PATH", pluginpath + ";" + Environment.GetEnvironmentVariable("GST_PLUGIN_SYSTEM_PATH"));
Environment.SetEnvironmentVariable("GST_DEBUG", "*:4");
Environment.SetEnvironmentVariable("GST_DEBUG_FILE", System.IO.Path.Combine(path, "gstreamer.log"));
Environment.SetEnvironmentVariable("GST_REGISTRY", registry);
来源:https://stackoverflow.com/questions/58732470/gstreamer-sharp-failed-to-create-pipeline