As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD's depth of features and ease of use. Today's project comes from Mohamed.
What it Does
This C# project will capture, DVR and stream videos over RTSP using LEADTOOLS Version 19.
Features Used
Development Progress Journal
My name is Mohamed and I'm going to create a program which will use our Multimedia toolkit to capture a live video stream, save it in the LEADTOOLS DVR file format, and then use our
RTSPServer
to stream the resulting DVR file while live capturing is still on.The streaming can be started soon after capturing begins, so it will be near-live streaming if the user wants it that way.
In this project, I will use the LEADTOOLS Multimedia SDK and program with .NET C# programming language. The LEADTOOLS Multimedia SDK provides me with the ability to Play, Capture and Convert media files. The project's process consists of the following parts:
- Create capture control and enumerate Available Audio and Video devices.
- Set the target format type of the
Capture
control to DVR so that video keeps getting added, while providing the ability to read from that recorded video without stopping capture.- Create
RTSPServer
and initialize the IP Address and port number for theRTSPServer
.- Stream the resulting DVR file.
First, I will start with a new Windows Forms Application in Visual Studio 2010. In the form, I will add a
Capture
control, two ComboBoxes for the Audio and Video devices, several buttons for each operation needs user action.I have now added the needed
Capture
control and other objects in the project. To work withCapture
control, I will need to use LEADTOOLSCaptureCtrl
Class:The program will enumerate the available video and audio capture devices in a comboboxes. Also it has the ability for changing the properties of the selected devices.
Handling the capturing from devices and saving as DVR only took me a little less than an hour because our Multimedia SDK greatly simplifies dealing with Multimedia features. If I was going to do it using DirectShow without LEADTOOLS, I'd probably need several days to do a similar simple application.
Next I will add a function for getting the v4 IP address of the machine.
The total time is now about 4 hours. This included the form design, handling the IP address, choosing the devices and saving the result as LBL format (LEADTOOLS DVR) with MPEG-4 video and AAC Audio compression.
Now, I will add the
RTSPSever
code. Based on what I've done so far with the LEADTOOLS Multimedia SDK, I expect this control to be just as high level and require a very small amount of code, even though the work it accomplishes is quite substantial.Documentation: Creating a RTSP Server
This part is now done and it took about half an hour to finish.
Next I will take a final look at the design to do some finishing touches...
This took about half an hour and I'm now satisfied with how the program looks and feels.
Lastly comes the testing part, for which I will try running the application on different machines and play the video on another machine. After an hour and a half, I think the program is solid and stable.
The total amount of time taken to develop, debug and test the application from scratch was less than 7 hours. Without LEADTOOLS Multimedia SDK, this application would not have been possible to finish within one day.
Download the Project
The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.