将RTSP存储到文件位置

我能够通过C#Winform应用程序在Windows 7 64位机器上流式传输rtsp。 这是我使用的库 – VLCDotNet ,这是播放RTSP流的代码示例:

LocationMedia media = new LocationMedia(@"rtsp://192.168.137.73:554/live.sdp"); vlcControl1.Media = media; vlcControl1.Play(); 

我想通过点击按钮将流存储到我的PC中的文件中,并使用另一个按钮停止相同的操作。 我如何实现这一目标?

这是代码:

 Vlc.DotNet.Core.Medias.MediaBase media1 = new Vlc.DotNet.Core.Medias.PathMedia("rtsp://192.168.137.73:554/live.sdp"); media.AddOption(":sout=#transcode{vcodec=theo,vb=800, scale=1,acodec=flac,ab=128,channels=2,samplerate=44100}:std{access=file,mux=ogg, dst=D:\\123.mp4}"); VlcControl control = new VlcControl(); control.Media = media; control.Play(); 
 VlcContext.StartupOptions.IgnoreConfig = true; VlcContext.StartupOptions.LogOptions.LogInFile = true; VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true; VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug; // Disable showing the movie file name as an overlay // VlcContext.StartupOptions.AddOption("--no-video-title-show"); // VlcContext.StartupOptions.AddOption("--no-audio"); VlcContext.StartupOptions.AddOption("--rtsp-tcp"); //this line was important to make this work 

从Vlc.DotNet.Core 2.1.62开始,执行此操作的方法是在vlc控件上使用.Play的额外opts参数。

 var opts = new string[] { @":sout=file/ogg:C:\video.ogg" }; vlc.MediaPlayer.Play(new Uri(videoURI), opts); 

`