public static void Run(string[] args) { // Initialize GStreamer Gst.Application.Init(ref args); GtkSharp.GstreamerSharp.ObjectManager.Initialize(); string fileName = @"U:/Video/test.avi"; // Get a list of all visualization plugins Gst.Registry registry = Registry.Get(); var list = registry.FeatureFilter(FilterEffectFeatures, false); _effects.AddRange(list.Select(pf => pf.Name)); foreach (var ef in _effects) { Console.WriteLine(ef); } _pipeline = new Pipeline(); _src = ElementFactory.Make("filesrc"); _dbin = ElementFactory.Make("decodebin"); _conv = ElementFactory.Make("videoconvert"); _scale = ElementFactory.Make("videoscale"); _navseek = ElementFactory.Make("navseek"); _queue = ElementFactory.Make("queue"); _sink = ElementFactory.Make("autovideosink"); if (new[] { _pipeline, _src, _dbin, _conv, _scale, _navseek, _queue, _sink }.Any(e => e == null)) { "Failed to create elements".PrintErr(); return; } _src["location"] = fileName; _pipeline.Add(_src, _dbin, _conv, _scale, _navseek, _queue, _sink); if (!Element.Link(_src, _dbin) || !Element.Link(_conv, _scale, _navseek, _queue, _sink)) { "Failed to link elements".PrintErr(); return; } _dbin.PadAdded += PadAddedCb; _loop = new GLib.MainLoop(); var bus = _pipeline.Bus; bus.AddSignalWatch(); bus.Message += MessageCb; if (_pipeline.SetState(State.Playing) == StateChangeReturn.Failure) { "Failed to go into PLAYING state".PrintErr(); return; } _loop.Run(); _pipeline.SetState(State.Null); _dbinSrcpad?.Dispose(); _pipeline.Dispose(); }
public static void Run(string[] args) { // Initialize GStreamer Application.Init(ref args); GtkSharp.GstreamerSharp.ObjectManager.Initialize(); // Get a list of all visualization plugins Gst.Registry registry = Registry.Get(); var list = registry.FeatureFilter(FilterVisFeatures, false); // Print their names Console.WriteLine("Available visualization plugins:"); ElementFactory selectedFactory = null; foreach (var walk in list) { ElementFactory factory = (ElementFactory)walk; var name = factory.Name; Console.WriteLine($" {name}"); if (selectedFactory == null && name.StartsWith("goom")) { selectedFactory = factory; } } /* Don't use the factory if it's still empty * e.g. no visualization plugins found */ if (selectedFactory == null) { Console.WriteLine("No visualisation plugins found"); return; } // We have now selected a factory for the visualization element Console.WriteLine($"Selected {selectedFactory.Name} "); var visPlugin = selectedFactory.Create(); if (visPlugin == null) { return; } // Not found // using (var pipeline = (Pipeline)Parse.Launch("playbin uri=http://1live.akacast.akamaistream.net/7/706/119434/v1/gnl.akacast.akamaistream.net/1live")) using (var pipeline = (Pipeline)Parse.Launch("playbin uri=http://radio.hbr1.com:19800/ambient.ogg")) { // Set the visualization flag var flags = (GstPlayFlags)pipeline["flags"]; flags |= GstPlayFlags.Vis; pipeline["flags"] = (uint)flags; // set vis plugin for playbin pipeline["vis-plugin"] = visPlugin; var ret = pipeline.SetState(State.Playing); if (ret == StateChangeReturn.Failure) { "Unable to set the pipeline to the playing state.".PrintErr(); return; } using (var bus = pipeline.Bus) { var msg = bus.TimedPopFiltered(Constants.CLOCK_TIME_NONE, MessageType.Error | MessageType.Eos); if (msg != null) { msg.Dispose(); } } pipeline.SetState(State.Null); } }