How to streaming video via VLC api in C#

后端 未结 1 987
南笙
南笙 2021-01-16 06:06

I\'m working on small home project for video broadcasting. I\'ve found some example Example, but it does not works, because needed old version of library 0.8.6. So I found i

相关标签:
1条回答
  • 2021-01-16 06:30

    I found a solution and used Vlc.DotNet wrapper I've installed nuget packages and wrote console app:

     class Program
    {
        static void Main(string[] args)
        {
            FileInfo file = new FileInfo(@"C:\Users\Jman\VideoMaker.avi");
    
            var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            // Default installation path of VideoLAN.LibVLC.Windows
            var libDirectory =
                new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
    
            using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory))
            {
    
                var mediaOptions = new[]
                {
                    ":sout=#rtp{sdp=rtsp://192.168.1.162:8008/test}",
                    ":sout-keep"
                };
    
                //mediaPlayer.SetMedia(new Uri("http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8"),
                //    mediaOptions);
    
                mediaPlayer.SetMedia(file, mediaOptions);
    
                mediaPlayer.Play();
    
                Console.WriteLine("Streaming on rtsp://192.168.1.162:8008/test");
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
            }
        }
    }
    

    Then I ran VLC media player and entered my link. And I got my videostream

    rtsp://192.168.1.162:8008/test

    0 讨论(0)
提交回复
热议问题