您能否指导我如何连续流式传输我的屏幕?
我在 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