简体   繁体   English

在Gstreamer(C#)中使用管道播放音频

[英]Playing Audio with pipeline in Gstreamer (C#)

I've been struggling with GStreamer for a while because I can't find any C# examples/tutorials. 我一直在GStreamer上苦苦挣扎,因为我找不到任何C#示例/教程。

As far as I know, Gstreamer uses pipelines in order to decode and then be able to send, for instance a song, to the speakers, but I tried the following, which didn't work: 据我所知,Gstreamer使用流水线进行解码,然后能够将(例如歌曲)发送给扬声器,但是我尝试了以下操作,但没有成功:

        Gst.Element pipeline;
        string path = @"some_path.mp3";
        string command = "filesrc location=" + path + " ! oggdemux ! vorbisdec ! audioconvert ! gconfaudiosink";
        pipeline = Gst.Parse.Launch(command);
        pipeline.SetState(Gst.State.Playing);

However, it raises an exception in the Gst.Parse.Launch line 但是,它在Gst.Parse.Launch行中引发异常

Does anyone know any good application example, and/or can actually post some code, so I can start getting used to the library? 有谁知道任何好的应用程序示例,并且/或者实际上可以发布一些代码,因此我可以开始习惯该库了? Also, if you can tell me what's wrong on the code above, I'd be thankful 另外,如果您能告诉我上面的代码出了什么问题,我将很感激

Without further ado, Regards 事不宜迟,敬上

Just change your command string to "filesrc location=" + path + " ! decodebin2 ! gconfaudiosink", that should work. 只需将您的命令字符串更改为“ filesrc location =” + path +“!解码bin2!gconfaudiosink”,就可以了。

On a side note you should use the gst-launch tool on the command line to check if your pipeline is working and to debug it. 附带说明一下,您应该在命令行上使用gst-launch工具来检查管道是否正常工作并对其进行调试。 Also use gst-inspect to find which plugins are available on your system and what is their functionality. 还可以使用gst-inspect查找系统上可用的插件以及它们的功能是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM