/// <summary> /// エンコードプロファイルの初期設定を行う /// </summary> private void InitEncodeProfile() { /* * IWMEncProfileCollection pc = this.enc.ProfileCollection; * * foreach (IWMEncProfile2 pf in pc) * { * if (pf.Name.StartsWith("Windows Media Video")) * { * this.group.set_Profile(pf); * break; * } * } */ //自分で作成したプロファイルを使用すると //データ送信前後の遅延が無くなる。 WMEncProfile2Class pf = new WMEncProfile2Class(); pf.LoadFromFile(new FileInfo("../../test1.prx").FullName); this.group.set_Profile(pf); // Marshal.ReleaseComObject(pc); }
/// <summary> /// �������ꂽ���f�B�A�t�@�C����������� /// </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); }
/// <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); }
public override Hashtable GetProfileInfos() { // 先清空 profileInfos.Clear(); // 声明必要变量 IWMEncSourcePluginInfoManager sourceGroupCollection = encoder.SourcePluginInfoManager; IWMEncProfileCollection profileCollection = encoder.ProfileCollection; IWMEncProfile2 profile2 = new WMEncProfile2Class(); // 刷新 sourceGroupCollection.Refresh(); // 将所有压缩方式的相关信息 依次存入 profileInfos(Hashtable)。 for (int i = 0; i < profileCollection.Count; i++) { // 利用wp2获取压缩方式的相关信息 profile2.LoadFromIWMProfile((IWMEncProfile)profileCollection.Item(i)); // 获取压缩方式的相关描述 StringBuilder profileInfo = new StringBuilder(); profileInfo.AppendLine(profileCollection.Item(i).Description); for (int j = 0; j < profile2.AudienceCount; j++) { IWMEncAudienceObj audienceObj = profile2.get_Audience(j); // 假如此听众处于被选中状态 if (audienceObj.Selected) { object audioCodecName = null; object videoCodecName = null; try { // 得到音频编码名称 int audioCodecIndex = audienceObj.get_AudioCodec(0); profile2.EnumAudioCodec(audioCodecIndex, out audioCodecName); // 得到视频编码名称 int videoCodecIndex = audienceObj.get_VideoCodec(0); profile2.EnumVideoCodec(videoCodecIndex, out videoCodecName); } catch { } // 假如音频编码名称不为NULL if (audioCodecName != null) { profileInfo.AppendLine("音频编码:" + audioCodecName.ToString()); } // // 假如频编码名称不为NULL if (videoCodecName != null) { profileInfo.AppendLine("视频编码:" + videoCodecName.ToString()); profileInfo.AppendLine("视频高度:" + Convert.ToString(audienceObj.get_VideoHeight(0)) + "\t视频宽度:" + Convert.ToString(audienceObj.get_VideoWidth(0))); } } } profileInfos.Add(profileCollection.Item(i).Name, profileInfo.ToString()); } return(profileInfos); }
/// <summary> /// �G���R�[�h�v���t�@�C���̏����ݒ��s�� /// </summary> private void InitEncodeProfile() { /* IWMEncProfileCollection pc = this.enc.ProfileCollection; foreach (IWMEncProfile2 pf in pc) { if (pf.Name.StartsWith("Windows Media Video")) { this.group.set_Profile(pf); break; } } */ //�����ō쐬�����v���t�@�C����g�p����� //�f�[�^���M�O��̒x���������Ȃ�B WMEncProfile2Class pf = new WMEncProfile2Class(); pf.LoadFromFile(new FileInfo("../../test1.prx").FullName); this.group.set_Profile(pf); // Marshal.ReleaseComObject(pc); }