private void EncodeFile(EncodingProfileEnum Profile, EncoderInfo Info)
        {
            try
            {
                m_CurrentInfo = Info;
                DateTime Now = DateTime.Now;
                lblStatus.Text = " Starting to encode " + m_CurrentProfile.ToString() +
                                 " Starting time = " + Now.ToLongTimeString();
                m_EncodingDone = false;
                // Create a WMEncoder object.
                m_Encoder = new WMEncoder();
                m_Encoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler(
                    OnStateChange);

                // Retrieve the source group collection.
                IWMEncSourceGroupCollection SrcGrpColl = m_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(Info.FileNameAndPath, "", "");
                // Specify a file object in which to save encoded content.
                SetOutputFileName(Info.FileNameNoExtension);
                SelectProfile(SrcGrp);

                // Fill in the description object members.
                IWMEncDisplayInfo Descr = m_Encoder.DisplayInfo;
                Descr.Author      = Info.Author;
                Descr.Copyright   = "Valley Bible Church @2005";
                Descr.Description = Info.Description;
                Descr.Rating      = "All Audiences";
                Descr.Title       = Info.MessageTitle;

                // Add an attribute to the collection.
                IWMEncAttributes Attr = m_Encoder.Attributes;
                Attr.Add("URL", "IP address");

                // Start the encoding process.
                // Wait until the encoding process stops before exiting the application.
                m_Encoder.PrepareToEncode(true);
                m_Encoder.Start();
            }
            catch (Exception e)
            {
                lblError.Text = e.ToString();
                Debug.WriteLine(e.ToString());
                m_CurrentInfo = null;
            }
        }
Example #2
0
        /**
         *  Title: String.
         *  Subject: String.
         *  Description: String.
         *  Source: String.
         *  Language: String.
         *  Relation: String.
         *  Coverage: String.
         *  Creator: String.
         *  Publisher: String.
         *  Contributor: String.
         *  Rights: String.
         *  Date: String.
         *  Type: String.
         *  Format: String.
         *  Identifier: String.
         */
        public DVRBResult SetMetadata(
            string title,
            string subject,
            string description,
            string source,
            string language,
            string relation,
            string coverage,
            string creator,
            string publisher,
            string contributor,
            string rights,
            string date,
            string type,
            string format,
            string identifier)
        {
            // Fill in the description object members.
            IWMEncDisplayInfo descr = this.wmEncoder.DisplayInfo;

            descr.Title       = title;
            descr.Description = description;
            descr.Author      = creator;
            descr.Copyright   = rights;

            // Add an attribute to the collection.
            IWMEncAttributes attr = this.wmEncoder.Attributes;

            attr.RemoveAll();
            attr.Add("title", title);
            attr.Add("subject", subject);
            attr.Add("description", description);
            attr.Add("source", source);
            attr.Add("language", language);
            attr.Add("relation", relation);
            attr.Add("coverage", coverage);
            attr.Add("creator", creator);
            attr.Add("publisher", publisher);
            attr.Add("contributor", contributor);
            attr.Add("rights", rights);
            attr.Add("date", date);
            attr.Add("type", type);
            attr.Add("format", format);
            attr.Add("identifier", identifier);
            return(new DVRBResult());
        }
Example #3
0
    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.
        }
    }