Page 1 of 1

Stream images or desktop screen

Posted: 18 Feb 2020 05:54
by ngdongit
Dear all supporters,

Could you please guide me how I can stream continuously my screen?
I use the libraries: LibVLCSharp, LibVLCSharp.WPF, VideoLAN.LibVLC.Windows on NuGet
This is my code, but it is not working.
I do not know how to update the stream continuously and the second videoView cannot display the screen image
Also, why can I stream a video .mp4, but not .avi?

Code: Select all

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

I search and see the command line:
vlc -I dummy fake:// --fake-file c:\1.jpg -vvv --sout #transcode{vcodec=mp4v,vb=1024,scale=1}:duplicate{dst=std{access=udp,mux=ts,dst=localhost:1234}}
But I do not know how to transfer to code.
Thank you.

Re: Stream images or desktop screen

Posted: 09 Mar 2020 16:27
by mfkl
This might help https://code.videolan.org/mfkl/libvlcsharp-samples/-/blob/master/ScreenRecorder/Program.cs

Re: Stream images or desktop screen

Posted: 29 Apr 2020 00:28
by technologue
@mfkl
I don't have C#. Is there an equivalent code in python?