LEADTOOLS and DirectShow

What is DirectShow

Filters and Filter Graphs

Filter Definitions

Filter Graphs

Connecting Filters

Some Common Filter Graphs

DirectShow "Merit System" Registries

Competing Codecs

Capture and Control

Where does the LEADTOOLS Multimedia SDK Fit In?

DirectShow Interfaces

DirectShow Extensions

Debugging

References

 

Table 1: Media Types Supported by the LEAD MPEG2 Multiplexer

 

What is DirectShow

Microsoft® DirectShow® is an extensible, filter-based framework, based on the Microsoft®  Windows®  Component Object Model (COM), that provides a common interface for media across many of Microsoft's programming languages. It can render or record media files on-demand by the user or developer. DirectShow also contains DirectX® plug-ins for audio signal processing, and DirectX Video Acceleration for accelerated video playback.

Microsoft produced the DirectShow multimedia framework and API, which replaced the Video for Windows technology (VFW), to enable software developers to perform various operations on media files. DirectShow development tools and documentation are distributed as part of the Microsoft Platform SDK. Eventually, Microsoft plans to replace DirectShow with Windows Media Foundation (WMF), beginning with Windows Vista.

Most video-related Windows applications, such as Microsoft's Windows Media Player, Winamp, and Windows Movie Maker, use DirectShow to manage multimedia content. DirectShow's most notable competitor is Apple Computer's QuickTime framework.

Filters and Filter Graphs

DirectShow divides multimedia task processing, such as video playback, into a set of steps. Each step, or stage in the processing of the data is called a filter. Filters are connected together by input and output pins. Filters can be connected in different ways for different tasks to build a filter graph that lists all necessary filters to perform a specific task. Developers can add custom effects or other filters at any stage in the graph, then render the results to a file, URL or camera.

DirectShow Base Classes, a set of C++ classes provided in the DirectShow SDK, are used to build most filters. These handle much of the creation, registration and connection logic for the filter.

Filter Definitions

Since the entire concept of rendering, converting, and capturing files in DirectShow in based on filters and filter graphs, it is important to understand the role of each filter.

Source filter. This is usually the first filter in the graph. It is responsible for reading the input data. The data may come from a file on disk, a network, or any other method.

Demulitplexer. This filter is responsible for splitting the media streams. It is usually connected to the source filter. For example, the filter input might be the actual file or network stream, while the output would be separate audio and video streams.

Video / Audio Decoder Also known as a decompressor, this is a module or algorithm to decompress data. . These filters handle the actual decoding or decompression. They do not demultiplex, so data should be demultiplexed before it is passed to the decoder. Therefore, they are usually connected to the demultiplexer output. For example, the video decoder input might be a compressed video stream The portion of the file holding the video data. The video data might be compressed to save disk space. The data has to be decompressed using a video decompressor Also known as a decoder, this is a module or algorithm to decompress data. before you can play (see) it. such as MPEG2, and the output could be raw video data.

Renderer. These filters are used to actually render data. Data could be audio, video, or both. For example, when playing a media file with both audio and video, a video renderer The DirectShow A multimedia framework and API produced by Microsoft for software developers to perform various operations with media files. Most Windows video-related applications on Windows, such as Microsoft's Windows Media Player, use DirectShow to manage multimedia content. component responsible for playing the video. Some renderers might have useful settings you can adjust if you have problems playing the video.DirectShow component responsible for playing the video. Some renderers might have useful settings you can adjust if you have problems playing the video. would handle displaying the video on the screen, and an audio renderer would handle directing the audio data to the sound device. The input of the renderer is usually uncompressed data coming from the decoder.

Audio / Video Encoder Also known as compressor, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder. . These filters are used to compress data, audio or video. The input is usually uncompressed audio or video data, and the output is the compressed version of the same data.

Multiplexer A module that combines audio and video into one file.. This filter is responsible for joining media streams. Input is usually compressed data from an audio/video encoder. The output is a single stream containing both video and audio data.

Sink Filter. These filters are usually the last filters in the graph. They can handle writing the data to disk to create a media file, or they can send the data to some other location, such as over a network.

Video / Audio Processor. These are usually custom filters used to perform some type of data processing or generate some type of event. LEAD has created many video and audio processors, such as the Video Resize Filter, used to resize a video stream. Usually, these filters only handle uncompressed data, so they would be inserted in the filter graph before the encoder or after the decoder.

Filter Graphs

DirectShow filter graphs are widely used in video playback, in which the filters provide steps such as file parsing, video and audio de-multiplexing, decompressing, and rendering. They are also used for video and audio recording and editing, and for interactive tasks such as DVD navigation. During rendering, the filter graph searches the Windows Registry for registered filters, builds the graph, connects the filters together, and, at the developer's request, plays, pauses, etc. based on the created graph. GraphEdit, a free utility that ships with the DirectShow SDK, can be used to build and test custom graphs, filter by filter.

Connecting Filters

Each filter in a filter graph handles a specific task, and each filter is usually designed to handle a specific type of data or stream.

For example, to create an MPEG2 file, you would need an MPEG2 Encoder and an MPEG2 Multiplexer. Most likely, the MPEG2 Encoder will only create MPEG2 compressed data and the MPEG2 Multiplexer will only accept MPEG2 video and certain types of audio related to MPEG2 as inputs. The same goes for decoding and demultiplexing. An MPEG2 Decoder will only decode MPEG2 video, and an MPEG2 Demultiplexer will only accept as inputs a stream containing MPEG2 video and certain types of audio related to MPEG2.

When you try to connect filters that do not agree on data types, the connection is usually refused and the graph will not run. This is why it is important to know what media types each filter supports.

For example, Table 1: Media Types Supported by the LEAD MPEG2 Multiplexer lists media types supported by the LEAD MPEG2 Multiplexer. If you attempt to connect any media type other than those listed to the input of the LEAD MPEG2 Multiplexer, it will refuse the connection.

 

Table 1: Media Types Supported by the LEAD MPEG2 Multiplexer

 

Video

Audio

Type:

MEDIATYPE_Video

MEDIATYPE_Audio

Subtypes:

MEDIATYPE_MPEG1Video

MEDIASUBTYPE_MPEG1Payload

MEDIASUBTYPE_MPEG2_VIDEO

MPEG1AudioPayload

MEDIASUBTYPE_MPEG1Audio

FORMAT_WaveFormatEx (WAVE_FORMAT_MPEGLAYER3 format)

MEDIASUBTYPE_MPEG2_AUDIO

MEDIASUBTYPE_DOLBY_AC3

MEDIASUBTYPE_DVD_LPCM_AUDIO

 

 

References

MSDN DirectShow documentation. Retrieved on July 7, 2007.

Wikipedia DirectShow entry. Retrieved on November 7, 2007

LEADTOOLS Multimedia API WebHelp

LEADTOOLS Multimedia COM WebHelp

LEADTOOLS DirectShow Filters