/// <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); }
public void SetProfile() { m_profileCollection = m_encoder.ProfileCollection; for (int i = 0; i < m_profileCollection.Count; i++) { m_profile = m_profileCollection.Item(i); if (m_profile.Name == Flag_configpro) { m_srcGrp.set_Profile(m_profile); break; } } }
private static IWMEncProfile SelectProfile(IWMEncoder enc, string name) { IWMEncProfile result = null; foreach (IWMEncProfile profile in enc.ProfileCollection) { if (profile.Name.StartsWith(name)) { result = profile; break; } } return(result); }
/// <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); }
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"; }
public void SetProfile() { m_profileCollection = m_encoder.ProfileCollection; for(int i = 0; i < m_profileCollection.Count; i++) { m_profile = m_profileCollection.Item(i); if( m_profile.Name == Flag_configpro) { m_srcGrp.set_Profile(m_profile); break; } } }
private void InitializeEncoder() { SrcGrpColl = Encoder.SourceGroupCollection; SrcGrp = SrcGrpColl.Add("SG_1"); SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcAud.SetInput("Default_Audio_Device", "Device", ""); SrcVid.SetInput("Default_Video_Device", "Device", ""); ProColl = Encoder.ProfileCollection; for (int i = 0; i < ProColl.Count; i++) { Pro = ProColl.Item(i); data.Add(Pro.Name); if (Pro.Name == Codec) { SrcGrp.set_Profile(Pro); break; } } BrdCst = Encoder.Broadcast; BrdCst.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, Port); }