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 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 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); }
/// <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; } } }