OK, Here is what I've come up with so far:
string appPath = @"C:\Users\ericp\Documents\Visual Studio
2008\Projects\EncodeStillImageTest\";
try
{
// Create a WMEncoder object.
WMEncoder Encoder = new WMEncoder();
//Encoder.Broadcast.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_PUSH_DISTRIBUTION,80);
// Specify a file object in which to save encoded content.
IWMEncFile2 File = (IWMEncFile2)Encoder.File;
File.FileDuration = (9000 / 10000);
File.LocalFileName = String.Format("{0}OutputFile.wmv",
appPath);
/* ADDING THIS CODE MAKES THE VIDEO BLANK
//Add audio
IWMEncSourceGroup audioGroup =
Encoder.SourceGroupCollection.Add("AUDIO_GROUP");
audioGroup.set_Profile(profile);
IWMEncAudioSource audioSource =
(IWMEncAudioSource)audioGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
audioSource.SetInput(appPath + "Audio.wav", "", "");
*/
//Add images
string fileName1 = string.Format("{0}Lady01.bmp", appPath);
string fileName2 = string.Format("{0}Lady02.bmp", appPath);
IWMEncSourceGroup2 frameSourceGroup =
(IWMEncSourceGroup2)Encoder.SourceGroupCollection.Add("SG1");
IWMEncVideoSource2 sourceVideo =
(IWMEncVideoSource2)frameSourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
IWMEncSourceGroup2 frameSourceGroup2 =
(IWMEncSourceGroup2)Encoder.SourceGroupCollection.Add("SG2");
IWMEncVideoSource2 sourceVideo2 =
(IWMEncVideoSource2)frameSourceGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
frameSourceGroup.SetAutoRollover(-1, "SG2");
sourceVideo.SetInput(fileName1, "", "");
sourceVideo2.SetInput(fileName2, "", "");
IWMEncProfileCollection ProColl = Encoder.ProfileCollection;
ProColl.ProfileDirectory = appPath;
ProColl.Refresh();
IWMEncProfile Pro;
for (int i = 0; i < ProColl.Count; i++)
{
Pro = ProColl.Item(i);
if (Pro.Name == "Test")
{
frameSourceGroup.set_Profile(Pro);
frameSourceGroup2.set_Profile(Pro);
break;
}
}
// Fill in the description object members.
IWMEncDisplayInfo Descr = Encoder.DisplayInfo;
Descr.Author = "Author name";
Descr.Copyright = "Copyright information";
Descr.Description = "Text description of encoded content";
Descr.Rating = "Rating information";
Descr.Title = "Title of encoded content";
// Add an attribute to the collection.
IWMEncAttributes Attr = Encoder.Attributes;
Attr.Add("URL", "IP address");
// Start the encoding process.
// Wait until the encoding process stops before exiting the
application.
Encoder.PrepareToEncode(true);
Encoder.Start();
Thread.Sleep(1000);
for (int index = 0; index <
Encoder.SourceGroupCollection.Count; index++)
{
Encoder.SourceGroupCollection.Active =
Encoder.SourceGroupCollection.Item(index);
Console.WriteLine(Encoder.SourceGroupCollection.Item(index).Name);
Thread.Sleep(3000);
}
Encoder.Stop();
Encoder.Flush();
}
catch (Exception error)
{
Console.WriteLine(error.Message);
Thread.Sleep(2000);
}
This code will fail at "frameSourceGroup.set_Profile(Pro);" with an error:
"The profile's media types must match the media types defined for the
session.". As I understand it this is telling me that the profile I created
is wrong. I have tried adjusting it a bunch of different ways but I can't
seem to find a combination that lets it pass. I have tried with audio and
without. I tried the "Image" codec and several others. I can't seem to get
one to work with the code.
I also found this solution which uses a combination of WMF and the Windows
Media SDK:
http://codebetter.com/blogs/brendan.tompkins/archive/2005/06/29/128620.aspx
It works but can only go down to 1 FPS as a way to extend the time the image
is on screen. It's basic approach is to render each frame and use a timer to
hold the image on screen--or something like that. But the underlying method
(from the wmf wrapper) won't accept anything but ulong as FPS--so .25 or
something like that is out.
I wish I could actually talk to someone who deveolped Photostory--just to
hear them say they didn't use the SDK to make it work :)
So I still have to conquer:
What is the correct profile?
How do I control the time the image is on screen?
How do I use Zooms and Pans on the image while its on screen?
If I find the answers I'll post them here.
Thanks,
-E.