0

Could you please guide me how I can stream continuously my screen?

I use the libraries: LibVLCSharp, LibVLCSharp.WPF, VideoLAN.LibVLC.Windows on NuGet

I do not know how to update the stream continuously and the second videoView cannot display the screen image

This is my code, but it is not working.

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

Thank you.

P/S: My first post is here: https://forum.videolan.org/viewtopic.php?f=4&t=152462

Thanh Dong
  • 3
  • 2
  • 6

1 Answers1

0

Screen Recording can be done in C# using VLC API. I have created a sample program to demonstrate this.

Please see my Stackoverflow answer here: https://stackoverflow.com/a/60386481/4082441

Karthick
  • 357
  • 4
  • 13
  • Thank you for you answer, but I would like to customize screen image before sending to the stream. How could the library do that? – Thanh Dong Apr 23 '20 at 14:37