Click here to Skip to main content
15,669,580 members
Articles / Programming Languages / C++
Posted 31 Mar 2013


2 bookmarked

Media Foundation Capture and Convert with LEADTOOLS 18

31 Mar 2013CPOL2 min read
Media Foundation Capture and Convert with LEADTOOLS 18

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.


LEAD Technologies has been winning awards for its DirectShow Multimedia SDKs for over a decade and has leveraged its expertise to provide the same world-class SDK for Microsoft Media Foundation. LEADTOOLS Version 18 makes it easy to add multimedia playback, capture and conversion functionality with high level, programmer friendly objects and classes.

In addition to the top-notch development interfaces for C++ and .NET, LEADTOOLS Multimedia 18 includes codecs, media sources, media sinks, processing transforms and more. Boasting outstanding quality, compression and speed, LEADTOOLS is the complete package for all of your Multimedia development needs.

Key Media Foundation Capture and Convert Features in LEADTOOLS Multimedia SDKs

  • Capture in HD from any device including capture cards, cameras, TV Tuners, live web streams and more
  • Convert and save captured data in real time directly to file, memory, or create live streams for the public Internet or encrypted networks
  • Use LEAD’s advanced encoders, decoders, media sources and media sinks for the market’s best performance, quality and compression
    • MPEG-4
    • MPEG-2
    • h.264
    • h.263
    • AAC
    • AC3
    • AMR
    • MKV
    • MXF
    • ISO
    • OGG
    • Process the audio/video data with LEAD’s Media Foundation Transforms
    • Video Stabilizer
    • Deinterlace
    • Resize
    • Rotate
    • Text Overlay
    • Video Callback
    • Volume
  • High level .NET and C/C++ interfaces for 32 and 64 bit development

The Media Foundation Code

LEADTOOLS includes high level controls that do all the hard work of constructing the necessary topologies (or graphs if you are using the DirectShow version) for capturing and converting audio/video data. They also both come with live preview windows and callback events to monitoring the progress and other control states.


There are many ways to capture audio and video, and LEADTOOLS supports them all. Whether you are capturing from a webcam, microphone, IP camera, television signal, or even a military-grade UAV, LEADTOOLS only requires a few lines of code.

// Select the first available video device.  To choose from a list,
// you could enumerate and populate a ComboBox or similar control
_capturectrl.VideoDevices[0].Selected = true;
// Set the file format
_capturectrl.TargetFormats.Selection = (int)TargetFormatType.MP4;
_capturectrl.TargetFile = "capture.mp4";
// Set the target video format
TargetVideoFormats targetvideoformats = 
targetvideoformats.Selection = targetvideoformats.IndexOf(
   Constants.MEDIASUBTYPE_H264); // H264
// Set other miscellaneous settings and start the capture
_capturectrl.Preview = true; // Display a live preview
_capturectrl.UseTimeLimit = true;
_capturectrl.TimeLimit = 10; // 10 seconds

Image 1


Similarly, converting a multimedia file is as simple as setting the source file, destination file, and output settings.

// Set the input file to convert
_convertctrl.SourceFile = 
   @"C:\LEADTOOLS Multimedia 18\Media\DaDa_H264.mp4";
// Set the File Format
_convertctrl.TargetFormat = TargetFormatType.WMV;
_convertctrl.TargetFile = "DaDa.wmv";
// Set the target video format
TargetVideoFormats targetvideoformats =
targetvideoformats.Selection = targetvideoformats.IndexOf(
   Constants.WMMEDIASUBTYPE_WMV3 + "/MP"); // Windows Media Video 9 (WMV) main profile
// Set the target audio format
TargetAudioFormats targetaudioformats = 
targetaudioformats.Selection = targetaudioformats.IndexOf(
   Constants.WMMEDIASUBTYPE_WMAudioV8); // Windows Media Audio (WMA)
// Set other miscellaneous settings and start the conversion
_convertctrl.Preview = true;

Download the Full Media Foundation Capture and Convert Example

You can download a fully functional demo which includes the features discussed above. To run these examples you will need the following:


Need help getting this sample up and going? Contact our support team for free technical support! For pricing or licensing questions, you can contact our sales team ( or call us at 704-332-5532.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Help desk / Support LEAD Technologies, Inc.
United States United States
Since 1990, LEAD has established itself as the world's leading provider of software development toolkits for document, medical, multimedia, raster and vector imaging. LEAD's flagship product, LEADTOOLS, holds the top position in every major country throughout the world and boasts a healthy, diverse customer base and strong list of corporate partners including some of the largest and most influential organizations from around the globe. For more information, contact or
This is a Organisation (No members)

Comments and Discussions

-- There are no messages in this forum --