This tutorial shows how to apply a video filter to a media file and perform playback with the
PlayCtrl in a WinForms C# application using the LEADTOOLS Multimedia SDK.
|Summary||This tutorial covers how to apply a video filter in a WinForms C# .NET 6 application.|
|Completion Time||15 minutes|
|Visual Studio Project||Download tutorial project (3 KB)|
|Platform||Windows WinForms C# Application|
|IDE||Visual Studio 2022|
|Development License||Download LEADTOOLS|
|Try it in another language|
The LEADTOOLS Multimedia Play Control contains many advanced features that simplify decoding, processing and playing back media from different sources such as files, memory buffers and network streams. The toolkit is shipped with various demos that make use of these features, such as the main Multimedia Player demo that has different editions in multiple programming languages.
Get familiar with the basic steps of creating a project and working with the
PlayCtrl class by reviewing the Add References and Set a License and Playback a Video File tutorials before working on the Apply a Filter to a Video File - WinForms C# tutorial.
Start with a copy of the project created in the Playback a Video File tutorial. If the project is not available, follow the steps in that tutorial to create it.
This tutorial requires the following local DLLs, which are located at
It also requires adding a reference to the required filter's COM DLL, which is located at
Different SDK features require different references. For a complete list, refer to Multimedia Files You Must Include With Your Application. In addition to this, the COM DLLs need to be registered on the deployment machine before they can be used.
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. For the purposes of this tutorial, the
Video Stabilizer filter will be used alongside the
Test_VideoStabilizer.avi video. This video can be found here:
In Solution Explorer, right-click on
Form1.cs and select View Code to display the code-behind of the form. Add the following statement to the lines that already exist in the
using block at the top.
// Using block at the top
openToolStripMenuItem_Click function to become as follows:
private void openToolStripMenuItem_Click(object sender, EventArgs e)
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = @"C:\LEADTOOLS22\Resources\Media";
dlg.FileName = "Test_VideoStabilizer.avi";
if (dlg.ShowDialog(this) == DialogResult.OK)
string inputFile = dlg.FileName;
Processor stabilizer = _play.VideoProcessors.FirstOrDefault(p => p.FriendlyName == "LEAD Video Stabilizer Filter");
if (stabilizer != null)
if(!_play.SelectedVideoProcessors.Contains(stabilizer)) // don't add it if it already exists.
// retrieve the filter's interface
LMVStabilizeLib.ILMVStabilize stabilize = (LMVStabilizeLib.ILMVStabilize)_play.GetSubObject(PlayObject.SelVideoProcessor);
//set the fill color to yellow
stabilize.BkFillColor = 0xffff;
_play.SourceFile = inputFile;
catch (Exception ex)
Run the project by pressing F5, or by selecting Debug -> Start Debugging.
If the steps are followed correctly, the application runs and applies the Video Stabilizer filter on playback of a media file using the
Open dialog box.
This tutorial showed how to apply a filter to a video file using the