View, Archive, and Play Live Streams from Cameras in C# and C

As we move further into the 21st century, the era of communication and social media continues to grow and evolve. Blogs, YouTube and other social media formats consume videos regularly. The ability to capture from these sources is mandatory.

With the LEADTOOLS Multimedia SDK, we are able to capture from these devices rather simply. This kind of setup could take significantly longer with DirectShow or Media Foundation. These calls streamline the entire development process and provide access to the streams with just a few lines of code.

First, we will need to detect if there are any available devices and account for the possibility that none can be found:


int deviceCount = capture.VideoDevices.Count;
if (deviceCount < 1)
{
Console.WriteLine("No compatible devices found. Exiting.");
return;
}

To specify the target file path and format, you set these properties:


capture.TargetFile = outputFile;
capture.TargetFormat = TargetFormatType.AVI;

Video and audio compressors:


// select a suitable video compressor
capture.VideoCompressors.MJpeg.Selected = true;
// select a suitable audio compressor if available
capture.AudioCompressors.AC3.Selected = true;

Next, you call the StartCapture() method to capture the live feed:


         //use CaptureMode.VideoAndAudio if an audio device is also selected.
         capture.StartCapture(CaptureMode.Video);

To end the capture:


 capture.StopCapture();

Now that the feed has been captured and saved, we need a way to play it back. This is even more simple. All we need is the file path to the file we saved, and the LEAD play control:


string mediaFile = @"File Path to saved media file";

         playCtrl.AutoStart = false;
         playCtrl.SourceFile = mediaFile;

         playCtrl.Run();

For more information on the LEADTOOLS Multimedia SDK, check out our full tutorial on the View, Archive, and Play Live Streams from Cameras in C# and C.

Try for Free

Download the LEADTOOLS SDK for free. It’s fully-functional for 60 days and comes with free chat and email support.

LEAD Is Here For You

Need help while you wait for more blogs and tutorials? Contact our support team for free technical support! For pricing or licensing questions, you can contact our sales team via email or call us at 704-332-5532.

This entry was posted in Multimedia Imaging and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *