Stream images or desktop screen

About encoding, codec settings, muxers and filter usage
ngdongit
New Cone
New Cone
Posts: 1
Joined: 18 Feb 2020 05:25

Stream images or desktop screen

Postby ngdongit » 18 Feb 2020 05:54

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.

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Stream images or desktop screen

Postby mfkl » 09 Mar 2020 16:27

This might help https://code.videolan.org/mfkl/libvlcsharp-samples/-/blob/master/ScreenRecorder/Program.cs
https://mfkl.github.io

technologue
New Cone
New Cone
Posts: 4
Joined: 28 Apr 2020 23:47

Re: Stream images or desktop screen

Postby technologue » 29 Apr 2020 00:28

@mfkl
I don't have C#. Is there an equivalent code in python?


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 30 guests