gpt4 book ai didi

linux - 如何在 Linux 上使用 LibvlcSharp?

转载 作者:太空宇宙 更新时间:2023-11-04 11:53:33 25 4
gpt4 key购买 nike

我正在尝试在 Linux 安装 (Ubuntu 18.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();
}
}

错误信息:

Unhandled Exception: LibVLCSharp.Shared.VLCException: Failed to perform instanciation on the native side. Make sure you installed the correct VideoLAN.LibVLC.[YourPlatform] package in your platform specific project at LibVLCSharp.Shared.Internal..ctor(Func1 create, Action1 release) at RadioRecorderLibVlcSharp.Program.Main(String[] args) in /media/RadioRecorderLibVlcSharp/Program.cs:line 19

谁能帮帮我?

谢谢

最佳答案

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

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com