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.