private IBaseFilter ConfigAsf(ICaptureGraphBuilder2 capGraph, string szOutputFileName, CaptureOptions.VideoCompression quality) { IFileSinkFilter pTmpSink = null; IBaseFilter asfWriter = null; int hr = capGraph.SetOutputFileName(MediaSubType.Asf, szOutputFileName, out asfWriter, out pTmpSink); Marshal.ThrowExceptionForHR(hr); try { IConfigAsfWriter lConfig = (IConfigAsfWriter)asfWriter; string profileData; int bitRate; switch (quality) { case CaptureOptions.VideoCompression.MinimalSize: bitRate = (int)(1000000.0 * (_inFrameWidth * _inFrameHeight * _FPS) / (720 * 1280 * 25)); break; case CaptureOptions.VideoCompression.Optimal: bitRate = (int)(2000000.0 * (_inFrameWidth * _inFrameHeight * _FPS) / (720 * 1280 * 25)); break; case CaptureOptions.VideoCompression.BestQuality: bitRate = (int)(4000000.0 * (_inFrameWidth * _inFrameHeight * _FPS) / (720 * 1280 * 25)); break; default: throw new ApplicationException("Internal error: unknown type of the required video codec"); } //Getting XML with profile. using (var reader = new StreamReader(Path.Combine(Directories.GetConfigDirectory(), "Encoder.prx"))) { profileData = reader.ReadToEnd(); } profileData = profileData.Replace("__FRAME_WIDTH__", _inFrameWidth.ToString()); profileData = profileData.Replace("__FRAME_HEIGHT__", _inFrameHeight.ToString()); profileData = profileData.Replace("__BIT_RATE__", bitRate.ToString()); // Get manager IWMProfileManager profileManager; WMUtils.WMCreateProfileManager(out profileManager); // Create profile IWMProfile profile; profileManager.LoadProfileByData(profileData, out profile); lConfig.ConfigureFilterUsingProfile(profile); } finally { Marshal.ReleaseComObject(pTmpSink); } return(asfWriter); }
private void Config() { IWMWriter pWMWriter; IWMProfileManager pWMProfileManager = null; IWMProfile pWMProfile = null; INSSBuffer pSample; // Profile id for "Windows Media Video 8 for Dial-up Modem (No audio, 56 Kbps)" Guid guidProfileID = new Guid(0x6E2A6955, 0x81DF, 0x4943, 0xBA, 0x50, 0x68, 0xA9, 0x86, 0xA7, 0x08, 0xF6); WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); pProfileManager2.LoadProfileByID(guidProfileID, out pWMProfile); WMUtils.WMCreateWriter(IntPtr.Zero, out pWMWriter); pWMWriter.SetProfile(pWMProfile); pWMWriter.SetOutputFilename("foo.out"); Marshal.ReleaseComObject(pWMProfile); Marshal.ReleaseComObject(pWMProfileManager); pWMWriter.BeginWriting(); pWMWriter.AllocateSample(MAXLENGTH, out pSample); m_pSample = (INSSBuffer3)pSample; }
private void Config() { IWMProfileManager profileManager; WMUtils.WMCreateProfileManager(out profileManager); m_pCodecInfo = (IWMCodecInfo)profileManager; }
private void Config() { IWMProfileManager pWMProfileManager; WMUtils.WMCreateProfileManager(out pWMProfileManager); m_pl = pWMProfileManager as IWMProfileManagerLanguage; }
private void Config() { IWMProfileManager pWMProfileManager; WMUtils.WMCreateProfileManager(out pWMProfileManager); m_pWMProfileManager2 = (IWMProfileManager2)pWMProfileManager; }
private void Config() { IWMProfileManager pWMProfileManager; WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); pProfileManager2.CreateEmptyProfile(WMVersion.V8_0, out m_pProfile); }
private void Config() { IWMProfileManager pWMProfileManager = null; IWMProfile pWMProfile = null; // Open the profile manager WMUtils.WMCreateProfileManager(out pWMProfileManager); pWMProfileManager.CreateEmptyProfile(WMVersion.V9_0, out pWMProfile); pWMProfile.CreateNewMutualExclusion(out m_pME); }
private void Config() { IWMProfileManager profileManager; WMUtils.WMCreateProfileManager(out profileManager); IWMProfileManager2 profMan2 = (IWMProfileManager2)profileManager; profMan2.SetSystemProfileVersion(WMVersion.V9_0); m_pCodecInfo = (IWMCodecInfo3)profileManager; }
private void Config() { IWMProfileManager pWMProfileManager; IWMProfile pProfile; WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pProfileManager2.CreateEmptyProfile(WMVersion.V8_0, out pProfile); pProfile.CreateNewStream(MediaType.Video, out m_sc); }
private void Config() { IWMProfile pProfile; IWMProfileManager pWMProfileManager; WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pWMProfileManager.CreateEmptyProfile(WMVersion.V9_0, out pProfile); m_ps = pProfile as IWMPacketSize; }
private void Config() { IWMProfileManager pWMProfileManager = null; IWMProfile pWMProfile = null; IWMProfile3 pWMProfile3 = null; // Open the profile manager WMUtils.WMCreateProfileManager(out pWMProfileManager); pWMProfileManager.CreateEmptyProfile(WMVersion.V9_0, out pWMProfile); pWMProfile3 = pWMProfile as IWMProfile3; pWMProfile3.CreateNewBandwidthSharing(out m_pBS); }
private void Config() { IWMProfileManager pWMProfileManager; IWMProfile pProfile; WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); pProfileManager2.CreateEmptyProfile(WMVersion.V8_0, out pProfile); m_pLang = pProfile as IWMLanguageList; }
private void Config() { IWMProfileManager pWMProfileManager; IWMProfile pProfile; WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); pProfileManager2.LoadProfileByID(guidProfileID, out pProfile); m_pProfile2 = (IWMProfile2)pProfile; }
private void Config() { IWMProfileManager pWMProfileManager; IWMProfile pProfile; Guid guidProfileID = new Guid("{5B16E74B-4068-45B5-B80E-7BF8C80D2C2F}"); WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); pProfileManager2.LoadProfileByID(guidProfileID, out pProfile); m_pProfile3 = (IWMProfile3)pProfile; }
private void Config() { IWMProfileManager pWMProfileManager; IWMStreamConfig sc; WMUtils.WMCreateProfileManager(out pWMProfileManager); IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; pProfileManager2.CreateEmptyProfile(WMVersion.V8_0, out m_pProfile); m_pProfile.CreateNewStream(MediaType.Video, out sc); m_pv = sc as IWMPropertyVault; }
private IWMProfile CreateProfile() { IWMProfileManager pWMProfileManager = null; IWMProfile pWMProfile = null; // Open the profile manager WMUtils.WMCreateProfileManager(out pWMProfileManager); // Convert pWMProfileManager to a IWMProfileManager2 IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; // Specify the version number of the profiles to use pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); pProfileManager2.LoadProfileByID(g, out pWMProfile); return(pWMProfile); }
private void InitAsfWriter(out IBaseFilter asfWriter, bool shittyQuality = false) { int hr; asfWriter = (IBaseFilter) new WMAsfWriter(); hr = m_FilterGraph.AddFilter(asfWriter, "ASF Writer"); Marshal.ThrowExceptionForHR(hr); if (shittyQuality) { return; } // Create an appropriate IWMProfile from the data // Open the profile manager IWMProfileManager profileManager; IWMProfile wmProfile = null; WMUtils.WMCreateProfileManager(out profileManager); // error message: The profile is invalid (0xC00D0BC6) // E.g. no <prx> tags string profile = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(customGoodProfile)); profileManager.LoadProfileByData(profile, out wmProfile); if (profileManager != null) { Marshal.ReleaseComObject(profileManager); profileManager = null; } // Config only if there is a profile retrieved // Set the profile on the writer IConfigAsfWriter configWriter = (IConfigAsfWriter)asfWriter; configWriter.ConfigureFilterUsingProfile(wmProfile); }
void ConfigureASFWriter(WMAsfWriter asf_filter, WTVStreamingVideoRequest strq, FrameSize SourceFrameSize) { int hr; // Now it's added to the graph, configure it with the selected WM Profile SendDebugMessage("Getting WM profile with quality of " + strq.Quality.ToString(), 0); WindowsMediaLib.IWMProfileManager profileManager; WMUtils.WMCreateProfileManager(out profileManager); IWMProfile wmProfile; string txtPrxProfile = getPRXProfileForQuality(strq.Quality); if (!(string.IsNullOrEmpty(txtPrxProfile))) { SendDebugMessage("Adjusting WM profile to fit video within designated frame size", 0); // SET VIDEO SIZE TO FIT WITHIN THE RIGHT FRAME SendDebugMessage("Source video size is " + SourceFrameSize.ToString(), 0); FrameSize containerSize = frameSizeForStreamRequest(strq); SendDebugMessage("Container size is " + containerSize.ToString(), 0); FrameSize newVideoSize = new FrameSize(SourceFrameSize, containerSize); SendDebugMessage("Output size is " + newVideoSize.ToString(), 0); SetProfileFrameSize(ref txtPrxProfile, newVideoSize); SetProfileCustomSettings(ref txtPrxProfile, ref strq); // returns immediately if not custom quality SendDebugMessage("Configuring ASF Writer with profile", 0); profileManager.LoadProfileByData(txtPrxProfile, out wmProfile); WindowsMediaLib.IConfigAsfWriter configWriter = (WindowsMediaLib.IConfigAsfWriter)asf_filter; configWriter.ConfigureFilterUsingProfile(wmProfile); configWriter.SetIndexMode(true); // yes index - DEFAULT /* Additional config - TEST * //DirectShowLib.IConfigAsfWriter2 configAsfWriter2 = (DirectShowLib.IConfigAsfWriter2)asf_filter; * //configAsfWriter2.SetParam(ASFWriterConfig.AutoIndex, 0, 0); // IT IS DEFAULT */ // (NOT WORKING) // SET ANAMORPHIC VIDEO MARKERS WITHIN STREAM (ASPECT RATIO) ******************************* UInt32 uiAspectX = (UInt32)SourceFrameSize.Width; byte[] bAspectX = BitConverter.GetBytes(uiAspectX); UInt32 uiAspectY = (UInt32)SourceFrameSize.Height; byte[] bAspectY = BitConverter.GetBytes(uiAspectY); DirectShowLib.IServiceProvider pServiceProvider; // http://msdn.microsoft.com/en-us/library/dd390985%28VS.85%29.aspx pServiceProvider = (DirectShowLib.IServiceProvider)asf_filter; DsGuid dsgIWMHeaderinfo = DsGuid.FromGuid(new Guid(GUIDs.IWMWriterAdvanced2)); object o3 = null; hr = pServiceProvider.QueryService(dsgIWMHeaderinfo, dsgIWMHeaderinfo, out o3); // FAILS IN A STA THREAD DsError.ThrowExceptionForHR(hr); IWMHeaderInfo headerinfo = (IWMHeaderInfo)o3; // Get access to WMwriterAdvanced2 object using pServiceProvider (poss not futureproof) (see http://groups.google.com/group/microsoft.public.win32.programmer.directx.video/browse_thread/thread/36b154d41cb76ffd/c571d6ef56de11af?#c571d6ef56de11af ) DsGuid dsgWMwriterAdvanced2 = DsGuid.FromGuid(new Guid(GUIDs.IWMWriterAdvanced2)); object o = null; hr = pServiceProvider.QueryService(dsgWMwriterAdvanced2, dsgWMwriterAdvanced2, out o); // FAILS IN A STA THREAD DsError.ThrowExceptionForHR(hr); IWMWriterAdvanced2 WMWriterAdvanced2 = null; WMWriterAdvanced2 = (IWMWriterAdvanced2)o; // Get Access to IWMHeaderInfo3 through WMWriterAdvanced2 object o2 = null; //pServiceProvider = (DirectShowLib.IServiceProvider)WMWriterAdvanced2; DsGuid dsgIWMHeaderInfo3 = DsGuid.FromGuid(new Guid(GUIDs.IWMHeaderInfo3)); hr = pServiceProvider.QueryService(dsgWMwriterAdvanced2, dsgIWMHeaderInfo3, out o2); // LET'S SEE DsError.ThrowExceptionForHR(hr); IWMHeaderInfo3 WMHeaderInfo3 = null; WMHeaderInfo3 = (IWMHeaderInfo3)o2; short pwIndex; // Add Aspect Ratio information WMHeaderInfo3.AddAttribute(2, "AspectRatioX", out pwIndex, AttrDataType.DWORD, 0, bAspectX, bAspectX.Length); WMHeaderInfo3.AddAttribute(2, "AspectRatioY", out pwIndex, AttrDataType.DWORD, 0, bAspectY, bAspectY.Length); // Try with other interface too headerinfo.SetAttribute(2, "AspectRatioX", AttrDataType.DWORD, bAspectX, Convert.ToInt16(bAspectX.Length)); headerinfo.SetAttribute(2, "AspectRatioY", AttrDataType.DWORD, bAspectY, Convert.ToInt16(bAspectY.Length)); // ************ DEINTERLACE (experimental) if (strq.DeInterlaceMode > 0) { DeInterlaceModes dimode = DeInterlaceModes.WM_DM_NOTINTERLACED; // Deinterlace Mode if (strq.DeInterlaceMode == 1) { dimode = DeInterlaceModes.WM_DM_DEINTERLACE_NORMAL; } else if (strq.DeInterlaceMode == 2) { dimode = DeInterlaceModes.WM_DM_DEINTERLACE_HALFSIZE; } // Index of video pin int pinIndex = FilterGraphTools.FindPinIndexByMediaType(currentOutputFilter, PinDirection.Input, MediaType.Video, MediaSubType.Null); byte[] bDiMode = BitConverter.GetBytes((int)dimode); short szOf = (short)bDiMode.Length; // Set to use deinterlace mode try { WMWriterAdvanced2.SetInputSetting(pinIndex, g_wszDeinterlaceMode, AttrDataType.DWORD, bDiMode, szOf); } catch (Exception ex) { SendDebugMessageWithException("Could not set interlace mode:", ex); } } } else { SendDebugMessage("Warning - PRX Profile string was empty; using default WM config."); } }
internal IEnumerable <WMAFormatInfo> EnumerateFormatInfo(IWMProfileManager pProfileManager2) { IWMProfileManager pProfileManager = null; try { if (pProfileManager2 == null) { WMUtils.WMCreateProfileManager(out pProfileManager); } var pCodecInfo3 = (pProfileManager2 ?? pProfileManager) as IWMCodecInfo3; int cCodecs; pCodecInfo3.GetCodecInfoCount(MediaType.Audio, out cCodecs); for (int iCodec = 0; iCodec < cCodecs; iCodec++) { int szCodecName = 0; pCodecInfo3.GetCodecName(MediaType.Audio, iCodec, null, ref szCodecName); var codecName = new StringBuilder(szCodecName); pCodecInfo3.GetCodecName(MediaType.Audio, iCodec, codecName, ref szCodecName); var attrDataType = new AttrDataType(); int dwAttrSize = 0; byte[] pAttrValue = new byte[4]; pCodecInfo3.GetCodecProp(MediaType.Audio, iCodec, Constants.g_wszIsVBRSupported, out attrDataType, pAttrValue, ref dwAttrSize); if (pAttrValue[0] != 1) { continue; } if (m_vbr) { pCodecInfo3.SetCodecEnumerationSetting(MediaType.Audio, iCodec, Constants.g_wszVBREnabled, AttrDataType.BOOL, new byte[] { 1, 0, 0, 0 }, 4); pCodecInfo3.SetCodecEnumerationSetting(MediaType.Audio, iCodec, Constants.g_wszNumPasses, AttrDataType.DWORD, new byte[] { 1, 0, 0, 0 }, 4); } else { pCodecInfo3.SetCodecEnumerationSetting(MediaType.Audio, iCodec, Constants.g_wszVBREnabled, AttrDataType.BOOL, new byte[] { 0, 0, 0, 0 }, 4); } int cFormat; pCodecInfo3.GetCodecFormatCount(MediaType.Audio, iCodec, out cFormat); for (int iFormat = 0; iFormat < cFormat; iFormat++) { IWMStreamConfig pStreamConfig; int cchDesc = 1024; StringBuilder szDesc = new StringBuilder(cchDesc); pCodecInfo3.GetCodecFormatDesc(MediaType.Audio, iCodec, iFormat, out pStreamConfig, szDesc, ref cchDesc); if (szDesc.ToString().Contains("(A/V)")) { continue; } try { var pProps = pStreamConfig as IWMMediaProps; int cbType = 0; AMMediaType pMediaType = null; pProps.GetMediaType(pMediaType, ref cbType); pMediaType = new AMMediaType(); pMediaType.formatSize = cbType - Marshal.SizeOf(typeof(AMMediaType)); pProps.GetMediaType(pMediaType, ref cbType); try { if (pMediaType.majorType == MediaType.Audio && pMediaType.formatType == FormatType.WaveEx && pMediaType.subType == m_subType) { var pcm = WaveFormatExtensible.FromMediaType(pMediaType).GetConfig(); if (PCM == null || (pcm.ChannelCount == PCM.ChannelCount && pcm.SampleRate == PCM.SampleRate && pcm.BitsPerSample >= PCM.BitsPerSample)) { yield return new WMAFormatInfo() { codec = iCodec, codecName = codecName.ToString(), format = iFormat, formatName = szDesc.ToString(), subType = pMediaType.subType, pcm = pcm } } ; } } finally { WMUtils.FreeWMMediaType(pMediaType); } } finally { Marshal.ReleaseComObject(pStreamConfig); } } } } finally { if (pProfileManager != null) { Marshal.ReleaseComObject(pProfileManager); } } }
public IWMWriter GetWriter() { IWMProfileManager pProfileManager = null; try { WMUtils.WMCreateProfileManager(out pProfileManager); var pCodecInfo3 = pProfileManager as IWMCodecInfo3; // We have to use the same pProfileManager for enumeration, // because it calls SetCodecEnumerationSetting, so chosenFormat.format // would not point to the same format for a pProfileManager // with different (default) settings, and GetCodecFormat // would return the wrong stream config. var formats = GetFormats(pProfileManager); if (this.EncoderMode != "") { formats.RemoveAll(fmt => fmt.modeName != this.EncoderMode); } if (formats.Count < 1) { throw new NotSupportedException("codec/format not found"); } if (formats.Count > 1) { throw new NotSupportedException("codec/format ambiguous"); } var chosenFormat = formats[0]; IWMStreamConfig pStreamConfig1; pCodecInfo3.GetCodecFormat(MediaType.Audio, chosenFormat.codec, chosenFormat.format, out pStreamConfig1); try { pStreamConfig1.SetStreamNumber(1); IWMProfile pProfile; pProfileManager.CreateEmptyProfile(WMVersion.V9_0, out pProfile); try { pProfile.AddStream(pStreamConfig1); IWMWriter pWriter; WMUtils.WMCreateWriter(IntPtr.Zero, out pWriter); try { pWriter.SetProfile(pProfile); } catch (Exception ex) { Marshal.ReleaseComObject(pWriter); throw ex; } return(pWriter); } finally { Marshal.ReleaseComObject(pProfile); } } finally { Marshal.ReleaseComObject(pStreamConfig1); } } finally { Marshal.ReleaseComObject(pProfileManager); } }
private void Config() { WMUtils.WMCreateProfileManager(out m_pWMProfileManager); }
private bool Initialize(string destinationFileName, VideoQuality videoQuality) { IWMProfileManager profileManagerTemp = null; IWMProfile profile = null; int inputCount = 0; Guid inputTypeId; bool success = false; try { #region Initialize Properties CurrentSampleIndex = 0; CurrentSampleTimeStamp = 0; VideoChannelIndex = -1; MediaWriterConfigured = false; MediaWriterIsWriting = false; #endregion #region Create ProfileManager WMUtils.WMCreateProfileManager(out profileManagerTemp); IWMProfileManager2 profileManager = (IWMProfileManager2)profileManagerTemp; #endregion #region Configure ProfileManager profileManager.SetSystemProfileVersion(WMVersion.V8_0); #endregion #region Load Profile switch (videoQuality) { case VideoQuality.Kbps128: profileManager.LoadProfileByData(Wilke.Interactive.Drone.Control.Properties.Resources.VideoProfile128kbps, out profile); break; case VideoQuality.Kbps256: profileManager.LoadProfileByData(Wilke.Interactive.Drone.Control.Properties.Resources.VideoProfile256kbps, out profile); break; } #endregion #region Create Writer WMUtils.WMCreateWriter(IntPtr.Zero, out mediaWriter); #endregion #region Configure Writer MediaWriter.SetProfile(profile); MediaWriter.GetInputCount(out inputCount); // Find the first video input on the writer for (int index = 0; index < inputCount; index++) { // Get the properties of channel #index MediaWriter.GetInputProps(index, out mediaProperties); // Read the type of the channel MediaProperties.GetType(out inputTypeId); // If it is video, we are done if (inputTypeId == MediaType.Video) { VideoChannelIndex = index; break; } } // Didn't find a video channel if (VideoChannelIndex == -1) { throw new Exception("Profile does not accept video input"); } MediaWriter.SetOutputFilename(destinationFileName); #endregion success = true; } catch { throw; } return(success); }
/// <summary> /// Create filename from specified profile using specified framerate /// </summary> /// <param name="lpszFileName">File name to create</param> /// <param name="guidProfileID">WM Profile to use for compression</param> /// <param name="iFrameRate">Frames Per Second</param> public CwmvFile(string lpszFileName, ref Guid guidProfileID, int iFrameRate) { Guid guidInputType; int dwInputCount; IWMProfileManager pWMProfileManager = null; IWMProfile pWMProfile = null; // Initialize all member variables m_iFrameRate = iFrameRate; m_dwVideoInput = -1; m_dwCurrentVideoSample = 0; m_msVideoTime = 0; m_pWMWriter = null; m_pInputProps = null; m_Init = false; try { // Open the profile manager WMUtils.WMCreateProfileManager(out pWMProfileManager); // Convert pWMProfileManager to a IWMProfileManager2 IWMProfileManager2 pProfileManager2 = (IWMProfileManager2)pWMProfileManager; // Specify the version number of the profiles to use pProfileManager2.SetSystemProfileVersion(WMVersion.V8_0); // Load the profile specified by the caller pProfileManager2.LoadProfileByID(guidProfileID, out pWMProfile); // Create a writer. This is the interface we actually write with WMUtils.WMCreateWriter(IntPtr.Zero, out m_pWMWriter); // Set the profile we got into the writer. This controls compression, video // size, # of video channels, # of audio channels, etc m_pWMWriter.SetProfile(pWMProfile); // Find out how many inputs are in the current profile m_pWMWriter.GetInputCount(out dwInputCount); // Assume we won't find any video pins m_dwVideoInput = -1; // Find the first video input on the writer for (int i = 0; i < dwInputCount; i++) { // Get the properties of channel #i m_pWMWriter.GetInputProps(i, out m_pInputProps); // Read the type of the channel m_pInputProps.GetType(out guidInputType); // If it is video, we are done if (guidInputType == MediaType.Video) { m_dwVideoInput = i; break; } } // Didn't find a video channel if (m_dwVideoInput == -1) { throw new Exception("Profile does not accept video input"); } // Specify the file name for the output m_pWMWriter.SetOutputFilename(lpszFileName); } catch { Close(); throw; } finally { // Release the locals if (pWMProfile != null) { Marshal.ReleaseComObject(pWMProfile); pWMProfile = null; } if (pWMProfileManager != null) { Marshal.ReleaseComObject(pWMProfileManager); pWMProfileManager = null; } } }