Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This topic describes the format of a saved DirectShow graph (.grf) file.

The docfile (storage file) contains a stream called ActiveMovieGraph. This single stream contains within it all the filters, filter names, file names, connections, and so on.

To load such a graph
  1. Pass the storage file name to RenderFile. It will recognize that this is not a media file but a saved graph, and will restore the graph.

    - or -

  2. Open the storage file (by using StgOpenStorage).

  3. Query the filter graph manager for IPersistStream.

  4. Open the L"ActiveMovieGraph" stream (by using IStorage::OpenStream).

  5. Pass the stream to the filter graph (by using IPersistStream::Load).

The syntax of the graph within the stream follows.

Copy Code
<graph> ::=
<version3><filters><connections><clock>END
| <version2><filters><connections>END
<version3> ::= 0003\r\n
<version2> ::= 0002\r\n
<clock> ::= CLOCK <b>
<required><b><clockid>\r\n
<required> ::= 1|0
<clockid> ::= <n>|<class id>
<filters ::= FILTERS <b>[<filter list><b>]
<connections> ::= CONNECTIONS [<b> <connection
list>]
<filter list> ::= [<filter> <b>] <filter
list>
<connection list> ::=
[<connection><b>]<connection list>
<filter> ::=
<n><b>"<name>"<b><class
id><b>[<file>]<length><b1><filter
data>
<file> ::= SOURCE "<name>"<b> | SINK
"<name>"<b>
<class id> ::= class id of the filter in standard string form
<name> ::= any sequence of characters NOT including "
<length> ::= character string representing unsigned decimal
number, for example, 23
			 this is the number of bytes of data that follow the
following space.
<b> ::= any combination of space, \t, \r, or \n
<b1> ::= exactly one space character
<n> ::= an identifier that will in fact be an integer, 0001,
0002, 0003, etc.
<connection> ::= <n1><b>"<pin1
id>"<b><n2><b>"<pin2 id>" <media
type>
<n1> ::= identifier of first filter
<n2> ::= identifier of second filter
<pin1 id> ::= <name>
<pin2 id> ::= <name>
<media type> ::= <major type><b><sub
type><b><flags><length><b1><format>
<major type> ::= <class id>
<sub type> ::= <class id>
<flags> ::=
<FixedSizeSamples><b><TemporalCompression><b>
<FixedSizeSamples> ::= 1|0
<TemporalCompression> ::= 1|0
<Format> ::=
<SampleSize><b><FormatType><b><FormatLength><b1><FormatData>
<FormatType> ::= class id of the format in standard string
form
<FormatLength> ::= character string representing unsigned
decimal number
			 this is the number of bytes of data that follow the
following space.
<FormatData> ::= binary data

On output there will be a new line (\r\n) per filter, one per connection, and one for each of the keywords FILTERS and CONNECTIONS. Each other case of <B> will be a single space.

The keywords FILTERS, CONNECTIONS, and END are not localizable.

The filter data and format data are binary, so they might contain incorrect line breaks, null values, and so on.

The following approximates what the output looks like (a connection line is long and so has been split for presentation here, <with comments enclosed like this>).

Copy Code
0002
<version 2 of the syntax>
FILTERS
0001 "Source" {00000000-0000-0000-0000-000000000001} SOURCE
"MyFile.mpg" 0000000000
<id   name   guid of the filter (need this to load it)   
		 source file name   no private data>
0002 "another filter" {00000000-0000-0000-0000-000000000002}
0000000008 XXXXXXXX
<id   name   guid   (this one is not a file source or sink)   8
bytes private data>
CONNECTIONS
0001 "Output pin" 0002 "In"   <no line break here>
<filter id pin id   filter id pin id  (output pin is first, then
input pin)>
	0000000172 {00000000-0000-0000-0000-000000000003}   <no line
break here>
<sample size,   media type major-type>
	{00000000-0000-0000-0000-000000000004} 1 0   <no line break
here>
<media type sub-type, fixed size samples, no temporal
compression>
	0000000093 {00000000-0000-0000-0000-000000000005} 18
YYYYYYYYYYYYYYYYYY
<length of format   format type   18 bytes of binary format
data>
END
where: 
  • XXX... represents filter data

  • YYY... represents format data

The strings and characters in the file are always in Unicode™.

See Also

Concepts

File Formats