Storing RTSP to a file location

流过昼夜 提交于 2019-11-30 05:44:48

问题


I am able to stream an rtsp on windows 7 64 bit machine through C# Winform application. This is the library i used - VLCDotNet and here is the code sample to play the RTSP stream:

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

I would like to store the streams to a file in my PC on a button click and stop the same with another button. How do i achieve this?


回答1:


Here is the code:

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



回答2:


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



回答3:


As of Vlc.DotNet.Core 2.1.62, The way to do this is use the extra opts param of the .Play on the vlc control.

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

`



来源:https://stackoverflow.com/questions/13071652/storing-rtsp-to-a-file-location

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!