Example #1
0
        /// <summary>
        /// 分割されたメディアファイルを結合する
        /// </summary>
        /// <param name="profileName"></param>
        private static void CombineParts(string profileName)
        {
            WMEncoderApp app = new WMEncoderAppClass();
            IWMEncoder2  enc = app.Encoder as IWMEncoder2;

            IWMEncSourceGroupCollection sgcol = enc.SourceGroupCollection;

            IWMEncProfile      profile = SelectProfile(enc, profileName);
            int                index   = 0;
            IWMEncSourceGroup2 sg2     = null;

            foreach (FileInfo fi in new DirectoryInfo(".").GetFiles("dest*.wmv"))
            {
                sg2 = sgcol.Add("sg" + index) as IWMEncSourceGroup2;
                sg2.set_Profile(profile);
                sg2.AutoSetFileSource(fi.FullName);

                if (index > 0)
                {
                    sg2.SetAutoRollover(-1, "sg" + (index - 1));
                }

                index++;
            }

            sgcol.Active = sg2;

            FileInfo destFile = new FileInfo("default_all.wmv");

            destFile.Delete();

            enc.File.LocalFileName = destFile.FullName;

            enc.PrepareToEncode(true);
            enc.Start();

            Console.WriteLine("combine start");

            while (enc.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
            {
                Thread.Sleep(2000);
            }

            Console.WriteLine("combine end");

            Marshal.ReleaseComObject(profile);
            Marshal.ReleaseComObject(sgcol);
            Marshal.ReleaseComObject(enc);
            Marshal.ReleaseComObject(app);
        }
Example #2
0
        /// <summary>
        /// 順番に分割処理を実施する
        /// </summary>
        /// <param name="inputFile"></param>
        /// <param name="profileName"></param>
        /// <param name="duration"></param>
        /// <param name="num"></param>
        private static void OrderTrim(string inputFile, string profileName, int duration, int num)
        {
            WMEncoderApp app = new WMEncoderAppClass();
            IWMEncoder2  enc = app.Encoder as IWMEncoder2;

            IWMEncSourceGroupCollection sgcol = enc.SourceGroupCollection;

            IWMEncProfile profile = SelectProfile(enc, profileName);

            for (int i = 0; i < num; i++)
            {
                if (sgcol.Count > 0)
                {
                    sgcol.Remove("sg1");
                }

                IWMEncSourceGroup2 sg = sgcol.Add("sg1") as IWMEncSourceGroup2;
                sg.AutoSetFileSource(inputFile);

                int start = (duration * i) / num;
                int end   = (duration * (i + 1) / num) - 30000;

                SetMark(sg, start, end);

                sg.set_Profile(profile);

                enc.File.LocalFileName = new FileInfo(string.Format("dest{0}.wmv", i)).FullName;
                enc.PrepareToEncode(true);

                enc.Start();

                Console.WriteLine("encode start : {0} - start:{1}, end:{2}", i, start, end);

                while (enc.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
                {
                    Thread.Sleep(2000);
                }

                Console.WriteLine("encode end : {0}", i);
            }

            Marshal.ReleaseComObject(profile);
            Marshal.ReleaseComObject(sgcol);
            Marshal.ReleaseComObject(enc);
            Marshal.ReleaseComObject(app);
        }
Example #3
0
        public MediaTrimer(string inputFile, string profileName)
        {
            this.inputFile = inputFile;

            this.app   = new WMEncoderAppClass();
            this.enc   = app.Encoder as IWMEncoder2;
            this.sgcol = enc.SourceGroupCollection;

            this.profile = SelectProfile(profileName);

            if (this.profile == null)
            {
                throw new ArgumentException("nothing profile", "profileName");
            }

            this.DestFile = "default.wmv";
        }
Example #4
0
        public MediaTrimer(string inputFile, string profileName)
        {
            this.inputFile = inputFile;

            this.app = new WMEncoderAppClass();
            this.enc = app.Encoder as IWMEncoder2;
            this.sgcol = enc.SourceGroupCollection;

            this.profile = SelectProfile(profileName);

            if (this.profile == null)
            {
                throw new ArgumentException("nothing profile", "profileName");
            }

            this.DestFile = "default.wmv";
        }
Example #5
0
        /// <summary>
        /// 分割されたメディアファイルを結合する
        /// </summary>
        /// <param name="profileName"></param>
        private static void CombineParts(string dir)
        {
            WMEncoderApp app = new WMEncoderAppClass();
            IWMEncoder2  enc = app.Encoder as IWMEncoder2;

            IWMEncSourceGroupCollection sgcol = enc.SourceGroupCollection;

            WMEncProfile2 pf = new WMEncProfile2Class();

            pf.LoadFromFile(dir + "/default.prx");

            int index = 0;
            IWMEncSourceGroup2 sg2 = null;

            foreach (FileInfo fi in new DirectoryInfo(dir).GetFiles("dest*.wmv"))
            {
                Console.WriteLine("target : {0}", fi.Name);

                sg2 = sgcol.Add("sg" + index) as IWMEncSourceGroup2;
                sg2.set_Profile(pf);

                IWMEncSource asrc = sg2.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                asrc.SetInput(fi.FullName, "", "");

                IWMEncSource vsrc = sg2.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                vsrc.SetInput(fi.FullName, "", "");

                //sg2.AutoSetFileSource(fi.FullName);

                if (index > 0)
                {
                    sg2.SetAutoRollover(-1, "sg" + (index - 1));
                }

                index++;
            }

            sgcol.Active = sg2;

            FileInfo destFile = new FileInfo("default_all.wmv");

            destFile.Delete();

            enc.File.LocalFileName = destFile.FullName;

            enc.PrepareToEncode(true);
            enc.Start();

            Console.WriteLine("combine start");

            while (enc.RunState != WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
            {
                Thread.Sleep(2000);
            }

            Console.WriteLine("combine end : 0x{0}", enc.ErrorState.ToString("X"));

            Marshal.ReleaseComObject(pf);
            Marshal.ReleaseComObject(sgcol);
            Marshal.ReleaseComObject(enc);
            Marshal.ReleaseComObject(app);
        }