private static IMFSinkWriter CreateSinkWriter(string outputFile) { // n.b. could try specifying the container type using attributes, but I think // it does a decent job of working it out from the file extension // n.b. AAC encode on Win 8 can have AAC extension, but use MP4 in win 7 // http://msdn.microsoft.com/en-gb/library/windows/desktop/dd389284%28v=vs.85%29.aspx IMFSinkWriter writer; var attributes = MediaFoundationApi.CreateAttributes(1); attributes.SetUINT32(MediaFoundationAttributes.MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 1); try { MediaFoundationInterop.MFCreateSinkWriterFromURL(outputFile, null, attributes, out writer); } catch (COMException e) { if (e.GetHResult() == MediaFoundationErrors.MF_E_NOT_FOUND) { throw new ArgumentException("Was not able to create a sink writer for this file extension"); } throw; } finally { Marshal.ReleaseComObject(attributes); } return(writer); }
// Token: 0x06000942 RID: 2370 RVA: 0x0001AFC4 File Offset: 0x000191C4 private static IMFSinkWriter CreateSinkWriter(string outputFile) { IMFAttributes imfattributes = MediaFoundationApi.CreateAttributes(1); imfattributes.SetUINT32(MediaFoundationAttributes.MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 1); IMFSinkWriter result; try { MediaFoundationInterop.MFCreateSinkWriterFromURL(outputFile, null, imfattributes, out result); } catch (COMException exception) { if (exception.GetHResult() == -1072875819) { throw new ArgumentException("Was not able to create a sink writer for this file extension"); } throw; } finally { Marshal.ReleaseComObject(imfattributes); } return(result); }