1

我正在尝试在 linux 安装(Ubuntu 18.04)上使用 LibvlcSharp。我正在按照所有说明进行操作,包括这个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:无法在本机端执行实例化。1 create, Action确保在 /media/RadioRecorderLibVlcSharp 中 RadioRecorderLibVlcSharp.Program.Main(String[] args) 的LibVLCSharp.Shared.Internal..ctor(Func 1 release) 平台特定项目中安装了正确的 VideoLAN.LibVLC.[YourPlatform] 包/Program.cs:第 19 行

任何人都可以帮助我吗?

谢谢

4

1 回答 1

0

你能试试apt-get install vlc吗?这似乎有助于在您的系统上获取所有必需的插件/deps(尽管它可能会从官方 ubuntu 代表中提取 vlc 2.x)。

于 2019-03-20T08:56:15.607 回答