When encoding files using the Expression Encoder SDK, you may find there are times when you want to examine the current metadata and/or change the metadata on the file you’re creating. Let’s say you want to go through all the metadata items on an item, you can do something like this.

MediaItem mediaItem = new MediaItem(@"C:\myvideo.wmv");
int metadataCount = 0;
foreach (KeyValuePair<string, string> pair in mediaItem.Metadata)
    Console.WriteLine(pair.Key + "-" + pair.Value);

More frequently you’ll probably want to specify certain metadata before encoding the file. You can do this by doing something like the following before calling the Job’s Encode method

mediaItem.Metadata[MetadataNames.Title] = "My Home Movies";
mediaItem.Metadata[MetadataNames.Author] = "Dean Rowe";

These are using the predefined metadata names that we’ve specified. If you want to specify your own custom metadata you can simply do something like

mediaItem.Metadata["Fred"] = "Foo";