This tutorial shows how to apply a video processing filter to a media file and perform playback in a Windows C DLL application using the LEADTOOLS Multimedia SDK.
Overview | |
---|---|
Summary | This tutorial covers how to apply a filter during playback of a video file in a Windows C DLL application. |
Completion Time | 20 minutes |
Visual Studio Project | Download tutorial project (18 KB) |
Platform | Windows API C++ Application |
IDE | Visual Studio 2017, 2019 |
Development License | Download LEADTOOLS |
Try it in another language |
|
Get familiar with the basic steps of creating a project 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 - Windows 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.
To access the interface of the processing filter, an additional reference is required. Open the pre-compiled header file (either pch.h
or stdafx.h
, depending on the version of Visual Studio used) and add the following line:
// Add LEAD Video Stabilize filter reference
#import "C:\LEADTOOLS22\Bin\CDLL\x64\LMVStabilizex.dll" no_namespace, named_guids
Note
For a complete list of which DLLs are required for specific multimedia features, refer to Multimedia Files You Must Include With Your DirectShow-based Application.
The License unlocks the features needed for the project. It must be set before any toolkit functionality is called. For details, including tutorials for different platforms, refer to Setting a Runtime License.
There are two types of runtime licenses:
Note
Adding LEADTOOLS 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.
Navigate to the main CPP file of the project, which contains the WndProc
function for the main window. Inside the WndProc
function, under the switch(wmId)
statement, modify the code below the ID_FILE_PLAY
case to become as follows:
// In WndProc(), under "case WM_COMMAND:"
switch (wmId)
{
case ID_FILE_PLAY:
{
TCHAR szFileName[260] = TEXT("Test_VideoStabilizer.avi"); // File name
pPlay->AutoStart = TRUE;
pPlay->VideoWindowSizeMode = ltmmSizeMode::ltmmNormal;
if (!GetLoadingFileName(hWnd, szFileName, ARRAYSIZE(szFileName)))
break;
if (pPlay->SelectedVideoProcessors->Count == 0) // don't add it if it already exists.
{
int nVideoStabilizer = pPlay->VideoProcessors->Find(L"@device:sw:{E526D606-22E7-494C-B81E-AC0A94BFE603}\\{E2B7DDDE-38C5-11D5-91F6-00104BDB8FF9}");
if (nVideoStabilizer >= 0)
{
IltmmProcessor* pFilter = pPlay->VideoProcessors->Item(nVideoStabilizer);
pPlay->SelectedVideoProcessors->Add(pFilter, 0);
// retrieve the filter's interface
IUnknownPtr pUnk = pPlay->GetSubObject(ltmmPlay_Object_SelVideoProcessor);
ILMVStabilize* pStabilize = NULL;
pUnk->QueryInterface(IID_ILMVStabilize, (void**)&pStabilize);
//set the fill color to yellow
pStabilize->BkFillColor = RGB(255, 255, 0);
pStabilize->Release();
}
}
pPlay->sourcefile = szFileName;
}
break;
// Keep rest of the code as is
Note
The string used to find the filter's index in the call to
pPlay->VideoProcessors->Find
can be obtained using the DirectShow Filter List Utility that's installed with LEADTOOLS.
Run the project by pressing F5, or by selecting Debug -> Start Debugging.
If the steps are followed correctly, the application runs and enables the user to open multimedia files and applies the LEAD Video Stabilizer Filter to the video being played back.
This tutorial covered how to add the necessary references to insert and apply a video processing filter to the Play control.