MediaElement & DirectShow

From MediaLooks Knowledge Base

Jump to: navigation, search

A quick guide to playing arbitrary content with MediaElement.

[edit] Overview

Below is a guide on how to bridge MediaElement and DirectShow. A DirectShow filter provided in the download archive enables playback of arbitrary content via MediaElement.

If you have any questions about this, please contact us.

[edit] Quick Guide

Finding the filters in GraphEdit.
Finding the filters in GraphEdit.
Sample graph for an AVI file.
Sample graph for an AVI file.
Sample graph for a DV device.
Sample graph for a DV device.
  1. Download this ZIP archive.
  2. Register the "MgWpfExt.dll" from the directory below:
    \MgWpfExt\Debug\Register.bat
  3. Prepare a graph in GraphEdit of the content that you want to play in MediaElement (web camera, camcorder, media file). Make sure that the graph is complete, i.e. renders are connected. Test the graph to make sure it plays out correctly.
  4. Insert MediaLooks MGRender filter (from "MediaLooks Filters" category). Remove the original renders and insert MGRender instead (make sure to connect both audio and video pins to the new renderer). Remove the original renders from graph. Save the graph as a .GRF file. Close GraphEdit.
  5. Prepare a .GRI file. It is a simple plain text file where the first line has to be the "MLMG" tag; the second line - full path to the .GRF file. Examples of the .GRI files can be found in the "WPF_Sample" folder.
  6. Open GraphEdit and load the .GRI file into it. Test playback. It should play the content of the .GRF file that the .GRI file links to.
  7. Open Windows Media Player (note: tested only with WMP10). Drag-n-drop the .GRI file into the Media Player window and test playback. Media Player should play the same graph as in the original .RGF file.
  8. Unpack "WPF_Sample.zip". Copy the .GRI file into the following directory:
    \WPF_Sample\CSharp\bin\Debug
  9. In the WPF_Sample edit the "Window1.xaml": replace the name of the .GRI file on line 27 with your .GRI file.
  10. Compile the WPF_Sample project and run it. The video from the .GRI/.GRF graph that you had specified should be visible in the window of the WPF_Sample application (through the text).

Enjoy MediaElement playing arbitrary DirectShow content!

[edit] External Links

Personal tools