1

I'm trying to use LibvlcSharp on a linux installation (Ubuntu 18.04). I'm following all the instructions, including this one Getting started on LibVLCSharp.Gtk for Linux but my application always crash. It's working perfectly on windows, because there we can add VideoLAN.LibVLC.Windows package, but I couldn't find someting similar for Linux.

My code:

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();
        }
    }

The error message:

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

Anyone can help me?

thanks

  • Did you install the libvlc and libvlc dev packages? which .net version are you using? .net core? mono? – cube45 Mar 20 '19 at 06:21
  • Hi! Yes, I've installed libvlc and libvlc-dev packages. I'm using .net core 2.1 and I followed all the instructions installing mono etc. – Wilder Lopes Mar 20 '19 at 18:41

1 Answers1

0

Can you try apt-get install vlc? That seems to help getting all the required plugins/deps on your system (though it will pull vlc 2.x from the official ubuntu rep probably).

mfkl
  • 1,914
  • 1
  • 11
  • 21
  • Hi! It's working now after apt-get install vlc command. I already had vlc installed in my linux so I thought it was not necessary. Thanks a lot! – Wilder Lopes Mar 20 '19 at 18:42
  • If this solves your issue, please mark it as an answer – cube45 Mar 20 '19 at 21:53
  • Thanks, this is confusing since there is no nuget package for native linux libraries. Unfortunately this also means it is not possible to do a fully bundled build of an app since this package is not available... – user169771 Jul 11 '22 at 15:20
  • sadly we don't have the manpower to handle shipping and maintaining all the native linux builds on nuget – mfkl Jul 12 '22 at 09:45