Help with Media Encoder 9, examples don't compile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    Help with Media Encoder 9, examples don't compile


    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 @

    in both CSharp and VB6. I can't get them to compile. Some of the
    objects listed (namely the IWMEncVideoSour ce2 object in CSharp and
    IWMEncAudioSour ce and IWMEncSourceGro up2 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.
  • Grinder

    #2
    Re: Help with Media Encoder 9, examples don't compile


    "Matt" <no@no.com> wrote in message
    news:k5jtgvcua1 aqoibedctk0agu5 aulupb9o5@4ax.c om...[color=blue]
    >
    > I'm trying to simply convert a .avi file recorded by our[/color]
    program to a[color=blue]
    > wmv file, of course compressed as possible.
    >
    > I've looked at the examples provided by microsoft @
    >[/color]
    http://msdn.microsoft.com/library/de...deexamples.asp[color=blue]
    > in both CSharp and VB6. I can't get them to compile. Some[/color]
    of the[color=blue]
    > objects listed (namely the IWMEncVideoSour ce2 object in[/color]
    CSharp and[color=blue]
    > IWMEncAudioSour ce and IWMEncSourceGro up2 objects in VB6)[/color]
    don't exist[color=blue]
    > in the library.
    >
    > I'm guessing this is because I don't have the right library[/color]
    or[color=blue]
    > something, but I have the Windows Media Encoder 9 SDK[/color]
    installed and[color=blue]
    > the reference set to Windows Media Encoder in both projects
    > (VB6/Csharp).
    >
    > If these really don't work with Encoder 9, can someone offer[/color]
    an[color=blue]
    > example how to use the encoder then? I just something quick,[/color]
    not[color=blue]
    > setting a lot of options, not doing anything special, just[/color]
    trying to[color=blue]
    > save space by compressing the .avi files with the encoder.[/color]

    Have you checked "Windows Media Encoder" in Project >
    References... ? It has the types for IWMEncVideoSour ce and
    WMEncSourceGrou p -- perhaps those are adequate?


    Comment

    • Matt

      #3
      Re: Help with Media Encoder 9, examples don't compile

      On Fri, 11 Jul 2003 11:26:04 -0500, "Grinder"
      <grinder@no.spa m.maam.com> wrote:

      I thought about that...and while the SourceGroup gave no errors, the
      audio didn't work with the video object.
      [color=blue]
      >Have you checked "Windows Media Encoder" in Project >
      >References.. . ? It has the types for IWMEncVideoSour ce and
      >WMEncSourceGro up -- perhaps those are adequate?
      >[/color]

      Comment

      • Matt

        #4
        Re: Help with Media Encoder 9, examples don't compile (Code Example Now Included)

        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
        'IWMEncVideoSou rce2' could not be found (are you missing a using
        directive or an assembly reference?)
        error @ this part of the code:
        "IWMEncVideoSou rce2 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.
        IWMEncSourceGro upCollection SrcGrpColl
        = Encoder.SourceG roupCollection;

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

        // Add a video and audio source to the
        source group.
        IWMEncSource SrcAud =
        SrcGrp.AddSourc e(WMENC_SOURCE_ TYPE.WMENC_AUDI O);
        SrcAud.SetInput ("C:\\Inputfile .mpg",
        "", "");

        IWMEncVideoSour ce2 SrcVid =
        (IWMEncVideoSou rce2)SrcGrp.Add Source(WMENC_SO URCE_TYPE.WMENC _VIDEO);
        SrcVid.SetInput ("C:\\Inputfile .mpg",
        "", "");

        // Crop 2 pixels from each edge of the
        video image.
        SrcVid.Cropping BottomMargin = 2;
        SrcVid.Cropping TopMargin = 2;
        SrcVid.Cropping LeftMargin = 2;
        SrcVid.Cropping RightMargin = 2;

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

        // Choose a profile from the
        collection.
        IWMEncProfileCo llection ProColl =
        Encoder.Profile Collection;
        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_Prof ile(Pro);
        break;
        }
        }

        // Fill in the description object
        members.
        IWMEncDisplayIn fo Descr =
        Encoder.Display Info;
        Descr.Author = "Author name";
        Descr.Copyright = "Copyright
        information";
        Descr.Descripti on = "Text description
        of encoded content";
        Descr.Rating = "Rating information";
        Descr.Title = "Title of encoded
        content";

        // Add an attribute to the collection.
        IWMEncAttribute s Attr =
        Encoder.Attribu tes;
        Attr.Add ("URL", "IP address");

        // Start the encoding process.
        // Wait until the encoding process
        stops before exiting the application.
        Encoder.Prepare ToEncode(true);
        Encoder.Start() ;
        Console.WriteLi ne("Press Enter when
        the file has been encoded.");
        Console.ReadLin e(); // Press Enter
        after the file has been encoded.
        }
        catch (Exception e)
        {
        // TODO: Handle exceptions.
        }
        }
        }


        }


        On Tue, 15 Jul 2003 07:32:44 GMT, yhhuang@online. microsoft.com
        (Yan-Hong Huang[MSFT]) wrote:
        [color=blue]
        >Hello Matt,
        >
        >Please refer to
        >http://msdn.microsoft.com/library/en...ngincsharp.asp
        >?frame=true to double check that you have added all the references.
        >
        >Also, please add using WMEncoderLib; in the code. Please refer to
        >http://msdn.microsoft.com/library/en...deosource2prep
        >rocesspass.asp ?frame=true for code samples.
        >
        >Hope it helps.
        >
        >Best regards,
        >Yanhong Huang
        >Microsoft Online Partner Support
        >
        >Get Secure! ¨C www.microsoft.com/security
        >This posting is provided "AS IS" with no warranties, and confers no rights.
        >[/color]

        Comment

        Working...