topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 1:16 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - GeraldCSilver [ switch to compact view ]

Pages: [1]
1
UrlSnooper / Re: What do you use to record rtsp://?
« on: October 14, 2014, 04:48 AM »
We are also using C#, specifically ozeki's camera sdk.

On this website u can read about how to create an onvif or rtsp network video recorder in C#. Using the following code (and the VoIPSDK.dll that can be downloaded from the previously webpage), you can easily record rtsp stream.

In the GetCamera method you need the provide the IP address of your rtsp IP camera, and the username and the password you use for login. !IMPORTANT: you need to use the "rtsp://" prefix in front of the ip address.

Code: C# [Select]
  1. GetCamera("rtsp://192.168.115.175:8080", "admin", "admin");


Code: C# [Select]
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using Ozeki.Media.IPCamera;
  5. using Ozeki.Media.MediaHandlers.Video;
  6. using Ozeki.Media.Video.Controls;
  7. using Ozeki.Media.MediaHandlers;
  8.  
  9. namespace Network_Video_Recorder01
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         private IIPCamera _camera;
  14.         private DrawingImageProvider _imageProvider;
  15.         private MediaConnector _connector;
  16.         private VideoViewerWF _videoViewerWf;
  17.         private MPEG4Recorder _mpeg4Recorder;
  18.  
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.             _imageProvider = new DrawingImageProvider();
  23.             _connector = new MediaConnector();
  24.             _videoViewerWf = new VideoViewerWF();
  25.             SetVideoViewer();
  26.         }
  27.  
  28.         private void SetVideoViewer()
  29.         {
  30.             CameraBox.Controls.Add(_videoViewerWf);
  31.             _videoViewerWf.Size = new Size(260, 180);
  32.             _videoViewerWf.BackColor = Color.Black;
  33.             _videoViewerWf.TabStop = false;
  34.             _videoViewerWf.Location = new Point(14, 19);
  35.             _videoViewerWf.Name = "_videoViewerWf";
  36.         }
  37.  
  38.         private void button_Connect_Click(object sender, EventArgs e)
  39.         {
  40.             _camera = IPCameraFactory.GetCamera("rtsp://192.168.115.175:8080", "admin", "admin");
  41.             _connector.Connect(_camera.VideoChannel, _imageProvider);
  42.             _videoViewerWf.SetImageProvider(_imageProvider);
  43.             _videoViewerWf.Start();
  44.             _camera.Start();
  45.         }
  46.  
  47.         private void Button_CaptureVideoStart_Click(object sender, EventArgs e)
  48.         {
  49.             var path = TextBox_SaveTo.Text;
  50.             if (!String.IsNullOrEmpty(path))
  51.                 StartVideoCapture(path);
  52.         }
  53.  
  54.         private void StartVideoCapture(string path)
  55.         {
  56.             var date = DateTime.Now.Year + "y-" + DateTime.Now.Month + "m-" + DateTime.Now.Day + "d-" +
  57.                        DateTime.Now.Hour + "h-" + DateTime.Now.Minute + "m-" + DateTime.Now.Second + "s";
  58.             string currentpath;
  59.             if (String.IsNullOrEmpty(path))
  60.                 currentpath = date + ".mp4";
  61.             else
  62.                 currentpath = path + "\\" + date + ".mp4";
  63.  
  64.             _mpeg4Recorder = new MPEG4Recorder(currentpath);
  65.             _mpeg4Recorder.MultiplexFinished += Mpeg4Recorder_MultiplexFinished;
  66.             _connector.Connect(_camera.AudioChannel, _mpeg4Recorder.AudioRecorder);
  67.             _connector.Connect(_camera.VideoChannel, _mpeg4Recorder.VideoRecorder);
  68.         }
  69.  
  70.         private void Mpeg4Recorder_MultiplexFinished(object sender, Ozeki.VoIP.VoIPEventArgs<bool> e)
  71.         {
  72.             _connector.Disconnect(_camera.AudioChannel, _mpeg4Recorder.AudioRecorder);
  73.             _connector.Disconnect(_camera.VideoChannel, _mpeg4Recorder.VideoRecorder);
  74.             _mpeg4Recorder.Dispose();
  75.         }
  76.  
  77.         private void Button_CaptureVideoStop_Click(object sender, EventArgs e)
  78.         {
  79.             StopVideoCapture();
  80.         }
  81.  
  82.         private void StopVideoCapture()
  83.         {
  84.             _mpeg4Recorder.Multiplex();
  85.             _connector.Disconnect(_camera.AudioChannel, _mpeg4Recorder.AudioRecorder);
  86.             _connector.Disconnect(_camera.VideoChannel, _mpeg4Recorder.VideoRecorder);
  87.         }
  88.  
  89.         private void Button_SaveTo_Click(object sender, EventArgs e)
  90.         {
  91.             var result = folderBrowserDialog1.ShowDialog();
  92.             if (result == DialogResult.OK)
  93.                 TextBox_SaveTo.Text = folderBrowserDialog1.SelectedPath;
  94.         }
  95.     }
  96. }

Pages: [1]