我试图在linux安装(Ubuntu18.04)上使用LibvlcSharp。我遵循所有的指示,包括这个Getting started on LibVLCSharp.Gtk for Linux但是我的应用程序总是崩溃。它在windows上运行得很好,因为在那里我们可以添加VideoLAN.LibVLC.windows包,但是我找不到类似的Linux包。
我的代码:

static void Main(string[] args)
    {
        // Record in a file "record.ts" located in the bin folder next to the app
        var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
        var destination = Path.Combine(currentDirectory, "record.ts");

        // Load native libvlc library
        Core.Initialize();

        using (var libvlc = new LibVLC())
        //var libvlc = "/usr/lib/x86_64-linux-gnu/";
        using (var mediaPlayer = new MediaPlayer(libvlc))
        {
            // Redirect log output to the console
            libvlc.Log += (sender, e) => Console.WriteLine($"[{e.Level}] {e.Module}:{e.Message}");

            // Create new media with HLS link
            var urlRadio = "http://transamerica.crossradio.com.br:9126/live.mp3";
            var media = new Media(libvlc, urlRadio, FromType.FromLocation);

            // Define stream output options.
            // In this case stream to a file with the given path and play locally the stream while streaming it.
            media.AddOption(":sout=#file{dst=" + destination + "}");
            media.AddOption(":sout-keep");

            // Start recording
            mediaPlayer.Play(media);

            Console.WriteLine($"Recording in {destination}");
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }

错误消息:
未处理的异常:LibVLCSharp.Shared.VLCException:未能在本机端执行实例关联。确保在特定于平台的项目中安装了正确的VideoLAN.LibVLC。[yourplant]包
在LibVLCSharp.Shared.Internal..ctor上(Func1 create, Action1版本)
在/media/RadioRecorderLibVlcSharp/Program.cs中的RadioRecorderLibVlcSharp.Program.Main(String[]args)处:第19行
有人能帮我吗?
谢谢

最佳答案

你能试一下吗?这似乎有助于在您的系统上获得所有必需的插件/dep(尽管它可能会从官方ubuntu rep中获取vlc 2.x)。

关于linux - 如何在Linux上使用LibvlcSharp?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55252502/

10-12 14:28