Windows Media Profiles

 

Windows Media Profiles

ASF Streams (files and network streams) are created by the ASFWriter according to configuration information which is stored as data in a Windows Media Profile or, simply, Profile. The Profile will contain data relating to audio and video bitrates, audio sampling rates, image width & height, and so on.

DirectShow contains 27 pre-defined Profiles ranging from basic audio-only very low bitrate streams intended for use with dial-up modems to full-blown DVD-quality video and stereo audio streams. A full description of the Microsoft System Profiles can be found on the msdn website. Each Profile is given a unique Profile_ID and these are defined in DSPack in \DirectX\WMF9.pas - so WMF9 needs to be included in a project's uses section before the System Profiles can be used.

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, DSPack, DSUtil, DirectShow9, WMF9;

There are, rather surprizingly, only two video-only Profiles - both of which are for very low resolution dial-up modem streams. When the ASFWriter creates the stream - based on the data in the Profile - it expects to find that the appropriate source filters have been configured by the Filter Graph Manager.

The demo in DSPack and the example shown on the previous pages here only have a video source filter in their Filter Graphs which explains why only two of the AsfWriter's Profiles - the two video-only Profiles - work without error. If you want to use a different Profile in order to obtain higher-bitrate video, you need to either include an audio source filter in the Filter Graph (so that the Filter Graph is 'compatible' with audio-plus-video Profile), or create a new higher bitrate video-only Profile of your own.

Adding an Audio Filter to the Filter Graph

The code below shows how the audio filter would be added to our existing project. It assumes, of course, that each filter has been configured previously by enumerating and selecting one of the system devices for each filter as shown in the DirectShow Tutorial


   // Assign AsfWriter Profile constant as defined in DSUtil.pas 
   AsfWriter1.Profile:= wmp_V80_256Video; 

   with FilterGraph1 as ICaptureGraphBuilder2 do
   begin
      RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter1 as IBaseFilter,
                     nil, VideoWindow1 as IBaseFilter);
      RenderStream(@PIN_CATEGORY_CAPTURE , nil, Filter1 as IBaseFilter,
                     nil,  ASFWriter1 as IBaseFilter);

      RenderStream(nil, nil, AudioFilter as IBaseFilter, nil, AsfWriter1 as IBaseFilter);
   end;
   FilterGraph1.Play;

Of course, that's not the complete solution because, now, the two video-only Profiles are no longer compatible with the Filter Graph! The full answer is to include the audio filter in the Filter Graph unless either of the video-only Profiles is to be used.

Note, also, that the code shows how an AsfWriter.Profile is set in code by using its constant as defined in DSPack. We could, of course, have set it in the Object Inspector, but setting it in code obviously allows for users to select a Profile.

It's important to recognise the AsfWriter.Profile is a constant defined in DSUtil.pas whereas the System Profiles, as listed on the Microsoft site, are GUIDs. Although, for example, the constant wmp_V80_256Video and the GUID WMProfile_V80_256Video are equivalent in that they refer to the same Profile, they are not interchangable so that, for example, AsfWriter1.Profile:= WMProfile_V80_256Video would cause an error: 'Incompatible types: TWMProfiles8 and TGUID'.

It becomes more important not to confuse the two when we create our own Profiles - as we'll see in the next section.

previous page | next page

1 | 2 | 3 | 4 | 5 | 6 |


This site and its contents are © Copyright 2005 - All Rights Reserved.