Help with Media Encoder 9, examples don't compile

M

Matt

I'm trying to simply convert a .avi file recorded by our program to a
wmv file, of course compressed as possible.

I've looked at the examples provided by microsoft @
http://msdn.microsoft.com/library/d...y/en-us/wmencode/htm/completecodeexamples.asp
in both CSharp and VB6. I can't get them to compile. Some of the
objects listed (namely the IWMEncVideoSource2 object in CSharp and
IWMEncAudioSource and IWMEncSourceGroup2 objects in VB6) don't exist
in the library.

I'm guessing this is because I don't have the right library or
something, but I have the Windows Media Encoder 9 SDK installed and
the reference set to Windows Media Encoder in both projects
(VB6/Csharp).

If these really don't work with Encoder 9, can someone offer an
example how to use the encoder then? I just something quick, not
setting a lot of options, not doing anything special, just trying to
save space by compressing the .avi files with the encoder.

Thanks much for whatever help you can offer.
 
G

Grinder

Matt said:
I'm trying to simply convert a .avi file recorded by our program to a
wmv file, of course compressed as possible.

I've looked at the examples provided by microsoft @
http://msdn.microsoft.com/library/d...y/en-us/wmencode/htm/completecodeexamples.asp
in both CSharp and VB6. I can't get them to compile. Some of the
objects listed (namely the IWMEncVideoSource2 object in CSharp and
IWMEncAudioSource and IWMEncSourceGroup2 objects in VB6) don't exist
in the library.

I'm guessing this is because I don't have the right library or
something, but I have the Windows Media Encoder 9 SDK installed and
the reference set to Windows Media Encoder in both projects
(VB6/Csharp).

If these really don't work with Encoder 9, can someone offer an
example how to use the encoder then? I just something quick, not
setting a lot of options, not doing anything special, just trying to
save space by compressing the .avi files with the encoder.

Have you checked "Windows Media Encoder" in Project >
References... ? It has the types for IWMEncVideoSource and
WMEncSourceGroup -- perhaps those are adequate?
 
M

Matt

On Fri, 11 Jul 2003 11:26:04 -0500, "Grinder"

I thought about that...and while the SourceGroup gave no errors, the
audio didn't work with the video object.
 
M

Matt

This is the source I have, direct from microsoft. I have WMEncoderLib
as a reference.

This source fails to compile with a
C:\mine\code\C#\Encoder\Class1.cs(29): The type or namespace name
'IWMEncVideoSource2' could not be found (are you missing a using
directive or an assembly reference?)
error @ this part of the code:
"IWMEncVideoSource2 SrcVid ="

Thanks for help you can offer

-Matt





CODE:
using System;
using WMEncoderLib;

namespace Matt
{
/// <summary>
/// Summary description for Class1.
/// </summary>

class EncodeFile
{
static void Main()
{
try
{
// Create a WMEncoder object.
WMEncoder Encoder = new WMEncoder();

// Retrieve the source group
collection.
IWMEncSourceGroupCollection SrcGrpColl
= Encoder.SourceGroupCollection;

// Add a source group to the
collection.
IWMEncSourceGroup SrcGrp =
SrcGrpColl.Add("SG_1");

// Add a video and audio source to the
source group.
IWMEncSource SrcAud =
SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
SrcAud.SetInput("C:\\Inputfile.mpg",
"", "");

IWMEncVideoSource2 SrcVid =
(IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
SrcVid.SetInput("C:\\Inputfile.mpg",
"", "");

// Crop 2 pixels from each edge of the
video image.
SrcVid.CroppingBottomMargin = 2;
SrcVid.CroppingTopMargin = 2;
SrcVid.CroppingLeftMargin = 2;
SrcVid.CroppingRightMargin = 2;

// Specify a file object in which to
save encoded content.
IWMEncFile File = Encoder.File;
File.LocalFileName =
"C:\\OutputFile.wmv";

// Choose a profile from the
collection.
IWMEncProfileCollection ProColl =
Encoder.ProfileCollection;
IWMEncProfile Pro;
for (int i = 0; i < ProColl.Count;
i++)
{
Pro = ProColl.Item(i);
if (Pro.Name == "Windows Media
Video 8 for Local Area Network (384 Kbps)")
{

SrcGrp.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();
Console.WriteLine("Press Enter when
the file has been encoded.");
Console.ReadLine(); // Press Enter
after the file has been encoded.
}
catch (Exception e)
{
// TODO: Handle exceptions.
}
}
}


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top