This tutorial shows how to add an input file and stream it using the LEADTOOLS Media Streaming SDK in a C# .NET Framework application.
|Summary||This tutorial covers how to add input source to streaming server in a C# .NET Framework application.|
|Completion Time||30 minutes|
|Visual Studio Project||Download tutorial project (3 KB)|
|Platform||Windows C# Console Application|
|IDE||Visual Studio 2017, 2019|
|Development License||Download LEADTOOLS|
The LEADTOOLS Media Streaming Server class includes a multitude of advanced features, many of which are shown in the demo projects shipped with the toolkit such as the Media Streaming Server demo.
This tutorial shows that even with a few lines of code and using the Server object's default settings, it can still be a very powerful component.
Get familiar with the basic steps of creating a project by reviewing the Add References and Set a License tutorial, before working on the Add Input Source to Media Streaming Server tutorial.
Start with a copy of the project created in the Add References and Set a License tutorial. If you do not have that project, follow the steps in that tutorial to create it.
This tutorial requires the following local DLLs, which are located at
Different SDK features require different references. For a complete list, refer to Media Streaming Files You Must Include With Your Application.
The License unlocks the features needed for the project. It must be set before any toolkit function is called. For details, including tutorials for different platforms, refer to Setting a Runtime License.
There are two types of runtime licenses:
Adding LEADTOOLS NuGet and local references and setting a license are covered in more detail in the Add References and Set a License tutorial.
With the project created, the references added, and the license set, coding can begin.
In Solution Explorer, open
Program.cs, then add
using Leadtools.MediaStreaming; and
using Leadtools; to the
using block at the top.
// Using block at the top
Add a new method called
StartStreaming(), and call it in the
Main method after the
SetLicense method call.
static void StartStreaming()
Server server = new Server(); // Leadtools.MediaStreaming.Server
NetworkProperties netProps = server.GetNetworkProperties();
string HttpUrl = "http://" + netProps.ActualIPAddress + ":" + netProps.Port + "/DaDa_H264.mp4";
netProps.MediaFolder = @"C:\LEADTOOLS22\Media";
Console.WriteLine("Streaming server started.");
Console.WriteLine("Attempting to playback stream in default browser using: " + HttpUrl);
Console.WriteLine("\nPress ESC to stop server and exit...");
while (Console.ReadKey(true).Key != ConsoleKey.Escape)
Console.WriteLine("To stop server, press ESC key.");
static void Main(string args)
Make sure to use a valid folder name for the
netProps.MediaFolder property. In the code above, "C:\LEADTOOLS22\Media" is used, but it can changed to a different location.
Also, place a valid MP4 video file in that folder to use it for testing. For this tutorial, the file
DaDa_H264.mp4 can be used, which is shipped with LEADTOOLS 22 Multimedia SDK in the
Run the project by pressing F5, or by selecting Debug -> Start Debugging.
If the steps were followed correctly, the application runs and starts streaming the video and attempts to launch the default web browser to play back the video on it.
This tutorial showed how to add a video source and stream it using the