0

您能否指导我如何连续流式传输我的屏幕?

我在 NuGet 上使用库:LibVLCSharp、LibVLCSharp.WPF、VideoLAN.LibVLC.Windows

不知道如何连续更新流,第二个videoView无法显示屏幕图像

这是我的代码,但它不起作用。

             Core.Initialize();                // instantiate the main libvlc object
            _libvlc = new LibVLC();

            // Stream screen
            var mediaPlayer = new MediaPlayer(_libvlc);
            vv.MediaPlayer = mediaPlayer;
            string[] options = { ":sout=#duplicate{dst=display{noaudio},dst=rtp{mux=ts,dst=10.0.100.114,port=8080,sdp=rtsp://10.0.100.114:8080/screen.sdp}" };
            var stream = new MemoryStream();
            var media = new Media(_libvlc, stream, options);
            mediaPlayer.Play(media);

            await Task.Run(() =>
            {
                while (true)
                {
                    vv.Dispatcher.Invoke(() =>
                   {
                       // HOW CAN I UPDATE THE STREAM ????
                       //stream.Dispose();
                       //stream.Close();
                       //var bytes = CaptureScreen();
                       //stream = new MemoryStream(bytes);

                       //media = new Media(_libvlc, stream, options);
                       //mediaPlayer.Media.Dispose();
                       //mediaPlayer.Media = media;
                       //mediaPlayer.Play();
                   });

                    Thread.Sleep(100);
                }
            });


            // Display from stream
            vv1.MediaPlayer = new MediaPlayer(_libvlc);
            var media = new Media(_libvlc, "rtsp://10.0.100.114/screen.sdp", FromType.FromLocation);
            vv1.MediaPlayer.Play(media);

谢谢你。

P/S:我的第一篇文章在这里:https ://forum.videolan.org/viewtopic.php?f=4&t=152462

4

1 回答 1

0

屏幕录制可以使用 VLC API 在 C# 中完成。我创建了一个示例程序来演示这一点。

请在此处查看我的 Stackoverflow 答案:https ://stackoverflow.com/a/60386481/4082441

于 2020-02-25T02:00:01.040 回答