Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing RTSP to a file location

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?

like image 915
Vinshi Avatar asked Oct 25 '12 15:10

Vinshi


People also ask

Can you record RTSP?

To record RTSP streams on Windows machines, you must first set up ffmpeg on your machine: Install FFMPEG and unzip it to C:\Program Files\ffmpeg\bin. Create a PATH entry. Open the Windows menu and type "Path".

Can I record a RTSP stream on vlc?

This is easily achieved with the media player VLC which can be downloaded from here. Once VLC is installed and the camera is connected to the computer. Press Media and click Open Network Stream... Choose the Network tab and enter RTSP:\\<IP-address-to-Camera>.

Does RTSP include audio?

The Real-Time Streaming Protocol (RTSP) [RFC2326] is used for transferring real-time multimedia data, including audio and video, between a server and a client.


2 Answers

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();
like image 145
Vinshi Avatar answered Sep 17 '22 16:09

Vinshi


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
like image 41
Rajiv Parikh Avatar answered Sep 18 '22 16:09

Rajiv Parikh