Guest User

Untitled

a guest
Jan 6th, 2020
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. file := "test.mp4"
  2. video_bitrate := 2000000
  3. duration := 5
  4. videodevice := "Lenovo EasyCamera"
  5. audiodevice := "Microphone (Realtek High Definition Audio)"
  6. ; ShowAllDevicesNames := true
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. setbatchlines -1
  15. LOAD_DLL_Mf_Mfplat_Mfreadwrite()
  16. MFStartup(version := 2, MFSTARTUP_FULL := 0)
  17. if (ShowAllDevicesNames = "")
  18. {
  19. VarSetCapacity(MFT_REGISTER_TYPE_INFO, 32, 0)
  20. DllCall("RtlMoveMemory", "ptr", &MFT_REGISTER_TYPE_INFO, "ptr", MF_GUID(GUID, "MFMediaType_Video"), "ptr", 16)
  21. DllCall("RtlMoveMemory", "ptr", &MFT_REGISTER_TYPE_INFO + 16, "ptr", MF_GUID(GUID, "MFVideoFormat_H264"), "ptr", 16)
  22. hardware_encoder := MFTEnumEx(MF_GUID(GUID, "MFT_CATEGORY_VIDEO_ENCODER"), MFT_ENUM_FLAG_HARDWARE := 0x04|MFT_ENUM_FLAG_SORTANDFILTER := 0x40, 0, &MFT_REGISTER_TYPE_INFO)
  23. msgbox % "hardware-encoder - " hardware_encoder
  24. if (hardware_encoder != "")
  25. {
  26. MFCreateAttributes(pMFAttributes, 4)
  27. IMFAttributes_SetUINT32(pMFAttributes, MF_GUID(GUID, "MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS"), true)
  28. }
  29. else
  30. MFCreateAttributes(pMFAttributes, 3)
  31. IMFAttributes_SetGUID(pMFAttributes, MF_GUID(GUID, "MF_TRANSCODE_CONTAINERTYPE"), MF_GUID(GUID1, "MFTranscodeContainerType_MPEG4"))
  32. IMFAttributes_SetUINT32(pMFAttributes, MF_GUID(GUID, "MF_SINK_WRITER_DISABLE_THROTTLING"), true)
  33. IMFAttributes_SetUINT32(pMFAttributes, MF_GUID(GUID, "MF_LOW_LATENCY"), true)
  34. MFCreateSinkWriterFromURL(file, 0, pMFAttributes, pSinkWriter)
  35. Release(pMFAttributes)
  36. pMFAttributes := ""
  37. }
  38.  
  39. deviceError := WidthMax := HeightMax := FpsMax := BitrateMax := StreamNumberVideo := TypeNumberVideo := NUM_CHANNELSMax := BITS_PER_SAMPLEMax := SAMPLES_PER_SECONDMax := BYTES_PER_SECONDMax := StreamNumberAudio := TypeNumberAudio := ""
  40. loop 2
  41. {
  42. if (A_Index = 1)
  43. LookingSource := "video"
  44. else
  45. LookingSource := "audio"
  46. MFCreateAttributes(pMFAttributes%LookingSource%, 1)
  47. IMFAttributes_SetGUID(pMFAttributes%LookingSource%, MF_GUID(GUID, "MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE"), MF_GUID(GUID1, "MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_" SubStr(LookingSource, 1, 3) "CAP_GUID"))
  48. MFEnumDeviceSources(pMFAttributes%LookingSource%, pppSourceActivate, pcSourceActivate)
  49. Loop % pcSourceActivate
  50. {
  51. IMFActivate := NumGet(pppSourceActivate + (A_Index - 1)*A_PtrSize)
  52. devicename := IMFActivate_GetAllocatedString(IMFActivate, MF_GUID(GUID, "MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME"))
  53. if ShowAllDevicesNames
  54. %LookingSource%devicenames .= devicename "`n"
  55. else if (devicename = %LookingSource%device)
  56. IMFActivate_ActivateObject(IMFActivate, IMFMediaSource := "{279a808d-aec7-40c8-9c6b-a6b492c78a66}", MediaSource%LookingSource%)
  57. Release(IMFActivate)
  58. IMFActivate := ""
  59. }
  60. DllCall("ole32\CoTaskMemFree", "ptr", pppSourceActivate)
  61. Release(pMFAttributes%LookingSource%)
  62. pMFAttributes%LookingSource% := ""
  63. if ShowAllDevicesNames
  64. {
  65. if (%LookingSource%devicenames = "")
  66. %LookingSource%devicenames .= "None`n"
  67. %LookingSource%devicenames := LookingSource ":`n" %LookingSource%devicenames
  68. if (A_Index = 1)
  69. Continue
  70. msgbox % clipboard := videodevicenames "`n" audiodevicenames
  71. ExitApp
  72. }
  73. if (MediaSource%LookingSource% = "") or (deviceError != "")
  74. {
  75. if (MediaSource%LookingSource% = "")
  76. deviceError .= "Cannot find " LookingSource " device - """ %LookingSource%device """`n"
  77. if (A_Index = 1) and (audiodevice != "")
  78. Continue
  79. msgbox % deviceError
  80. ExitApp
  81. }
  82. if (A_Index = 1)
  83. {
  84. if (hardware_encoder != "")
  85. {
  86. MFCreateAttributes(pMFAttributes, 3)
  87. IMFAttributes_SetUINT32(pMFAttributes, MF_GUID(GUID, "MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS"), true)
  88. }
  89. else
  90. MFCreateAttributes(pMFAttributes, 2)
  91. IMFAttributes_SetUINT32(pMFAttributes, MF_GUID(GUID, "MF_LOW_LATENCY"), true)
  92. IMFAttributes_SetUINT32(pMFAttributes, MF_GUID(GUID, "MF_SOURCE_READER_DISCONNECT_MEDIASOURCE_ON_SHUTDOWN"), true)
  93. }
  94. MFCreateSourceReaderFromMediaSource(MediaSource%LookingSource%, pMFAttributes, SourceReader)
  95. loop
  96. {
  97. n := A_Index - 1
  98. loop
  99. {
  100. k := A_Index - 1
  101. if (IMFSourceReader_GetNativeMediaType(SourceReader, n, k, ppMediaType) = "MF_E_NO_MORE_TYPES")
  102. break
  103. if (IMFSourceReader_GetNativeMediaType(SourceReader, n, k, ppMediaType) = "MF_E_INVALIDSTREAMNUMBER")
  104. {
  105. VideoStreamCount := n
  106. break 2
  107. }
  108. IMFAttributes_GetGUID(ppMediaType, MF_GUID(GUID, "MF_MT_MAJOR_TYPE"), pguidValue)
  109. IMFAttributes_GetGUID(ppMediaType, MF_GUID(GUID, "MF_MT_SUBTYPE"), pguidValueSubType)
  110. if (LookingSource = "video") and (MemoryDifference(&pguidValue, MF_GUID(GUID, "MFMediaType_Video"), 16) = 0) and ((MemoryDifference(&pguidValueSubType, MF_GUID(GUID, "MFVideoFormat_I420"), 16) = 0) or (MemoryDifference(&pguidValueSubType, MF_GUID(GUID, "MFVideoFormat_IYUV"), 16) = 0) or (MemoryDifference(&pguidValueSubType, MF_GUID(GUID, "MFVideoFormat_NV12"), 16) = 0) or (MemoryDifference(&pguidValueSubType, MF_GUID(GUID, "MFVideoFormat_YUY2"), 16) = 0) or (MemoryDifference(&pguidValueSubType, MF_GUID(GUID, "MFVideoFormat_YV12"), 16) = 0) or (MemoryDifference(&pguidValueSubType, MF_GUID(GUID, "MFVideoFormat_RGB32"), 16) = 0))
  111. {
  112. IMFAttributes_GetUINT64(ppMediaType, MF_GUID(GUID, "MF_MT_FRAME_SIZE"), FRAME_SIZE)
  113. IMFAttributes_GetUINT64(ppMediaType, MF_GUID(GUID, "MF_MT_FRAME_RATE"), FRAME_RATE)
  114. if (IMFAttributes_GetUINT32(ppMediaType, MF_GUID(GUID, "MF_MT_AVG_BITRATE"), AVG_BITRATE) = "MF_E_ATTRIBUTENOTFOUND")
  115. AVG_BITRATE := 0
  116. WidthCurrent := FRAME_SIZE >> 32
  117. HeightCurrent := 0xFFFFFFFF & FRAME_SIZE
  118. FpsCurrent := (FRAME_RATE>>32)/(0xFFFFFFFF & FRAME_RATE)
  119. BitrateCurrent := AVG_BITRATE
  120. if (WidthCurrent > WidthMax) or ((WidthCurrent = WidthMax) and (HeightCurrent > HeightMax)) or ((WidthCurrent = WidthMax) and (HeightCurrent = HeightMax) and (FpsCurrent > FpsMax)) or ((WidthCurrent = WidthMax) and (HeightCurrent = HeightMax) and (FpsCurrent = FpsMax) and (BitrateCurrent > BitrateMax))
  121. {
  122. WidthMax := WidthCurrent
  123. HeightMax := HeightCurrent
  124. FpsMax := FpsCurrent
  125. BitrateMax := BitrateCurrent
  126. StreamNumberVideo := n
  127. TypeNumberVideo := k
  128. }
  129. }
  130. if ((LookingSource = "audio") or (audiodevice = "")) and (MemoryDifference(&pguidValue, MF_GUID(GUID, "MFMediaType_Audio"), 16) = 0) and ((MemoryDifference(&pguidValueSubType, MF_GUID(GUID, "MFAudioFormat_PCM"), 16) = 0) or (MemoryDifference(&pguidValueSubType, MF_GUID(GUID, "MFAudioFormat_Float"), 16) = 0))
  131. {
  132. setformat, IntegerFast, hex
  133. a .= NumGet(pguidValueSubType)
  134. setformat, IntegerFast, d
  135. if (IMFAttributes_GetUINT32(ppMediaType, MF_GUID(GUID, "MF_MT_AUDIO_AVG_BYTES_PER_SECOND"), BYTES_PER_SECOND) = "MF_E_ATTRIBUTENOTFOUND")
  136. BYTES_PER_SECOND := 0
  137. if (IMFAttributes_GetUINT32(ppMediaType, MF_GUID(GUID, "MF_MT_AUDIO_BITS_PER_SAMPLE"), BITS_PER_SAMPLE) = "MF_E_ATTRIBUTENOTFOUND")
  138. BITS_PER_SAMPLE := 0
  139. if (IMFAttributes_GetUINT32(ppMediaType, MF_GUID(GUID, "MF_MT_AUDIO_SAMPLES_PER_SECOND"), SAMPLES_PER_SECOND) = "MF_E_ATTRIBUTENOTFOUND")
  140. SAMPLES_PER_SECOND := 0
  141. if (IMFAttributes_GetUINT32(ppMediaType, MF_GUID(GUID, "MF_MT_AUDIO_NUM_CHANNELS"), NUM_CHANNELS) = "MF_E_ATTRIBUTENOTFOUND")
  142. NUM_CHANNELS := 0
  143. if ((NUM_CHANNELSMax < 2) and (NUM_CHANNELS > NUM_CHANNELSMax)) or ((NUM_CHANNELSMax = 2) and (NUM_CHANNELS = 6)) or ((NUM_CHANNELSMax > 2) and (NUM_CHANNELSMax != 6) and ((NUM_CHANNELS = 2) or (NUM_CHANNELS = 6))) or ((NUM_CHANNELS = NUM_CHANNELSMax) and (BITS_PER_SAMPLEMax != 16) and ((BITS_PER_SAMPLE = 16) or (BITS_PER_SAMPLE > BITS_PER_SAMPLEMax))) or ((NUM_CHANNELS = NUM_CHANNELSMax) and (BITS_PER_SAMPLE = BITS_PER_SAMPLEMax) and (SAMPLES_PER_SECONDMax != 44100) and (SAMPLES_PER_SECONDMax != 48000) and ((SAMPLES_PER_SECOND = 44100) or (SAMPLES_PER_SECOND > SAMPLES_PER_SECONDMax))) or ((SAMPLES_PER_SECONDMax != 48000) and (SAMPLES_PER_SECOND = 48000)) or ((NUM_CHANNELS = NUM_CHANNELSMax) and (BITS_PER_SAMPLE = BITS_PER_SAMPLEMax) and (SAMPLES_PER_SECOND = SAMPLES_PER_SECONDMax) and (BYTES_PER_SECOND > BYTES_PER_SECONDMax))
  144. {
  145. NUM_CHANNELSMax := NUM_CHANNELS
  146. BITS_PER_SAMPLEMax := BITS_PER_SAMPLE
  147. SAMPLES_PER_SECONDMax := SAMPLES_PER_SECOND
  148. BYTES_PER_SECONDMax := BYTES_PER_SECOND
  149. StreamNumberAudio := n
  150. TypeNumberAudio := k
  151. }
  152. }
  153. Release(ppMediaType)
  154. ppMediaType := ""
  155. }
  156. }
  157. if (audiodevice != "")
  158. {
  159. Release(SourceReader)
  160. SourceReader := ""
  161. }
  162. if (audiodevice = "") or (A_Index = 2)
  163. {
  164. msgbox % clipboard := a
  165. ExitApp
  166. if (A_Index = 2)
  167. {
  168. if (StreamNumberAudio != "")
  169. StreamNumberAudio += VideoStreamCount
  170. else
  171. {
  172. msgbox AudioSource not supported!
  173. ExitApp
  174. }
  175. MFCreateCollection(MFCollection)
  176. IMFCollection_AddElement(MFCollection, MediaSourceVideo)
  177. IMFCollection_AddElement(MFCollection, MediaSourceAudio)
  178. MFCreateAggregateSource(MFCollection, AggSource)
  179. Release(MFCollection)
  180. MFCollection := ""
  181. MFCreateSourceReaderFromMediaSource(AggSource, pMFAttributes, SourceReader)
  182. }
  183. IMFSourceReader_SetStreamSelection(SourceReader, MF_SOURCE_READER_ALL_STREAMS := 0xFFFFFFFE, false)
  184. IMFSourceReader_SetStreamSelection(SourceReader, StreamNumberVideo, true)
  185. if (StreamNumberAudio != "")
  186. IMFSourceReader_SetStreamSelection(SourceReader, StreamNumberAudio, true)
  187. IMFSourceReader_GetNativeMediaType(SourceReader, StreamNumberVideo, TypeNumberVideo, ppMediaType)
  188. IMFAttributes_GetGUID(ppMediaType, MF_GUID(GUID, "MF_MT_SUBTYPE"), pguidValue)
  189. IMFAttributes_GetUINT32(ppMediaType, MF_GUID(GUID, "MF_MT_INTERLACE_MODE"), INTERLACE_MODE)
  190. IMFAttributes_GetUINT64(ppMediaType, MF_GUID(GUID, "MF_MT_FRAME_SIZE"), FRAME_SIZE)
  191. IMFAttributes_GetUINT64(ppMediaType, MF_GUID(GUID, "MF_MT_FRAME_RATE"), FRAME_RATE)
  192. IMFAttributes_GetUINT64(ppMediaType, MF_GUID(GUID, "MF_MT_PIXEL_ASPECT_RATIO"), ASPECT_RATIO)
  193. Release(ppMediaType)
  194. Release(pMFAttributes)
  195. ppMediaType := pMFAttributes := ""
  196. if (audiodevice = "")
  197. break
  198. }
  199. }
  200.  
  201. loop 2 ; 1 - input, 2 - output
  202. {
  203. MFCreateMediaType(pMediaTypeVideo%A_Index%)
  204. IMFAttributes_SetGUID(pMediaTypeVideo%A_Index%, MF_GUID(GUID, "MF_MT_MAJOR_TYPE"), MF_GUID(GUID1, "MFMediaType_Video"))
  205. if (A_Index = 1)
  206. IMFAttributes_SetGUID(pMediaTypeVideo%A_Index%, MF_GUID(GUID, "MF_MT_SUBTYPE"), &pguidValue)
  207. else
  208. {
  209. IMFAttributes_SetGUID(pMediaTypeVideo%A_Index%, MF_GUID(GUID, "MF_MT_SUBTYPE"), MF_GUID(GUID1, "MFVideoFormat_H264"))
  210. IMFAttributes_SetUINT32(pMediaTypeVideo%A_Index%, MF_GUID(GUID, "MF_MT_AVG_BITRATE"), video_bitrate)
  211. }
  212. IMFAttributes_SetUINT32(pMediaTypeVideo%A_Index%, MF_GUID(GUID, "MF_MT_INTERLACE_MODE"), INTERLACE_MODE)
  213. IMFAttributes_SetUINT64(pMediaTypeVideo%A_Index%, MF_GUID(GUID, "MF_MT_FRAME_SIZE"), FRAME_SIZE)
  214. IMFAttributes_SetUINT64(pMediaTypeVideo%A_Index%, MF_GUID(GUID, "MF_MT_FRAME_RATE"), FRAME_RATE)
  215. IMFAttributes_SetUINT64(pMediaTypeVideo%A_Index%, MF_GUID(GUID, "MF_MT_PIXEL_ASPECT_RATIO"), ASPECT_RATIO)
  216. }
  217. IMFSinkWriter_AddStream(pSinkWriter, pMediaTypeVideo2, videoStreamIndex)
  218. IMFSinkWriter_SetInputMediaType(pSinkWriter, videoStreamIndex, pMediaTypeVideo1, 0)
  219. IMFSourceReader_SetCurrentMediaType(SourceReader, StreamNumberVideo, 0, pMediaTypeVideo1)
  220. Release(pMediaTypeVideo1)
  221. Release(pMediaTypeVideo2)
  222. pMediaTypeVideo1 := pMediaTypeVideo2 := ""
  223.  
  224. if (StreamNumberAudio != "")
  225. {
  226. if (NUM_CHANNELSMax = 0)
  227. NUM_CHANNELSMax := 1
  228. else if (NUM_CHANNELSMax > 2) and (NUM_CHANNELSMax < 6)
  229. NUM_CHANNELSMax := 2
  230. else if (NUM_CHANNELSMax > 6)
  231. NUM_CHANNELSMax := 6
  232. if (SAMPLES_PER_SECONDMax < 44100)
  233. SAMPLES_PER_SECONDMax := 44100
  234. else if (SAMPLES_PER_SECONDMax > 44100)
  235. SAMPLES_PER_SECONDMax := 48000
  236. loop 2 ; 1 - input, 2 - output
  237. {
  238. MFCreateMediaType(pMediaTypeAudio%A_Index%)
  239. IMFAttributes_SetGUID(pMediaTypeAudio%A_Index%, MF_GUID(GUID, "MF_MT_MAJOR_TYPE"), MF_GUID(GUID1, "MFMediaType_Audio"))
  240. if (A_Index = 1)
  241. IMFAttributes_SetGUID(pMediaTypeAudio%A_Index%, MF_GUID(GUID, "MF_MT_SUBTYPE"), MF_GUID(GUID1, "MFAudioFormat_PCM"))
  242. else
  243. {
  244. IMFAttributes_SetGUID(pMediaTypeAudio%A_Index%, MF_GUID(GUID, "MF_MT_SUBTYPE"), MF_GUID(GUID1, "MFAudioFormat_AAC"))
  245. IMFAttributes_SetUINT32(pMediaTypeAudio%A_Index%, MF_GUID(GUID, "MF_MT_AUDIO_AVG_BYTES_PER_SECOND"), 20000)
  246. }
  247. IMFAttributes_SetUINT32(pMediaTypeAudio%A_Index%, MF_GUID(GUID, "MF_MT_AUDIO_BITS_PER_SAMPLE"), 16)
  248. IMFAttributes_SetUINT32(pMediaTypeAudio%A_Index%, MF_GUID(GUID, "MF_MT_AUDIO_SAMPLES_PER_SECOND"), SAMPLES_PER_SECONDMax)
  249. IMFAttributes_SetUINT32(pMediaTypeAudio%A_Index%, MF_GUID(GUID, "MF_MT_AUDIO_NUM_CHANNELS"), NUM_CHANNELSMax)
  250. }
  251. IMFSinkWriter_AddStream(pSinkWriter, pMediaTypeAudio2, audioStreamIndex)
  252. IMFSinkWriter_SetInputMediaType(pSinkWriter, audioStreamIndex, pMediaTypeAudio1, 0)
  253. IMFSourceReader_SetCurrentMediaType(SourceReader, StreamNumberAudio, 0, pMediaTypeAudio1)
  254. Release(pMediaTypeAudio1)
  255. Release(pMediaTypeAudio2)
  256. pMediaTypeAudio1 := pMediaTypeAudio2 := ""
  257. }
  258. IMFSinkWriter_BeginWriting(pSinkWriter)
  259.  
  260. CaptureStart := start := ""
  261. CaptureDuration := duration*1000
  262. loop
  263. {
  264. IMFSourceReader_ReadSample(SourceReader, MF_SOURCE_READER_ANY_STREAM := 0xFFFFFFFE, 0, ActualStreamIndex, StreamFlags, Timestamp, pSample)
  265. if (ActualStreamIndex = StreamNumberVideo)
  266. ActualStreamIndex := videoStreamIndex
  267. else
  268. ActualStreamIndex := audioStreamIndex
  269. if (CaptureStart = "") and (pSample != 0) and (ActualStreamIndex = videoStreamIndex)
  270. {
  271. CaptureStart := 1
  272. TimestampStart := Timestamp
  273. start := A_TickCount
  274. }
  275. if CaptureStart
  276. {
  277. if (pSample != 0)
  278. {
  279. if (gap%ActualStreamIndex% = 1)
  280. {
  281. IMFAttributes_SetUINT32(pSample, MF_GUID(GUID, "MFSampleExtension_Discontinuity"), true)
  282. gap%ActualStreamIndex% := ""
  283. }
  284. IMFSample_SetSampleTime(pSample, Timestamp - TimestampStart)
  285. IMFSinkWriter_WriteSample(pSinkWriter, ActualStreamIndex, pSample)
  286. }
  287. else if (StreamFlags & MF_SOURCE_READERF_STREAMTICK := 256)
  288. {
  289. IMFSinkWriter_SendStreamTick(pSinkWriter, ActualStreamIndex, Timestamp - TimestampStart)
  290. gap%ActualStreamIndex% := 1
  291. }
  292. }
  293. if (pSample != 0)
  294. {
  295. Release(pSample)
  296. pSample := ""
  297. }
  298. if ((A_TickCount - start) >= CaptureDuration)
  299. break
  300. }
  301. IMFSinkWriter_Finalize(pSinkWriter)
  302. Release(SourceReader)
  303. IMFMediaSource_Shutdown(MediaSourceVideo)
  304. Release(MediaSourceVideo)
  305. if (audiodevice != "")
  306. {
  307. IMFMediaSource_Shutdown(MediaSourceAudio)
  308. IMFMediaSource_Shutdown(AggSource)
  309. Release(MediaSourceAudio)
  310. Release(AggSource)
  311. MediaSourceAudio := AggSource := ""
  312. }
  313. Release(pSinkWriter)
  314. SourceReader := MediaSourceVideo := pSinkWriter := ""
  315. MFShutdown()
  316. msgbox done
  317. ExitApp
  318.  
  319.  
  320.  
  321. LOAD_DLL_Mf_Mfplat_Mfreadwrite()
  322. {
  323. if !DllCall("GetModuleHandle","str","Mf")
  324. DllCall("LoadLibrary","Str", "Mf.dll", "ptr")
  325. if !DllCall("GetModuleHandle","str","Mfplat")
  326. DllCall("LoadLibrary","Str", "Mfplat.dll", "ptr")
  327. if !DllCall("GetModuleHandle","str","Mfreadwrite")
  328. DllCall("LoadLibrary","Str", "Mfreadwrite.dll", "ptr")
  329. }
  330.  
  331. MFStartup(version, dwFlags)
  332. {
  333. hr := DllCall("Mfplat.dll\MFStartup", "uint", version, "uint", dwFlags)
  334. if hr or ErrorLevel
  335. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  336. }
  337.  
  338. MFShutdown()
  339. {
  340. hr := DllCall("Mfplat.dll\MFShutdown")
  341. if hr or ErrorLevel
  342. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  343. }
  344.  
  345. MFTEnumEx(guidCategory, Flags, pInputType, pOutputType)
  346. {
  347. if (A_PtrSize = 8)
  348. hr := DllCall("Mfplat\MFTEnumEx", "ptr", guidCategory, "uint", Flags, "ptr", pInputType, "ptr", pOutputType, "ptr*", pppMFTActivate, "uint*", pnumMFTActivate)
  349. else
  350. hr := DllCall("Mfplat\MFTEnumEx", "uint64", NumGet(guidCategory+0, 0, "uint64"), "uint64", NumGet(guidCategory+0, 8, "uint64"), "uint", Flags, "ptr", pInputType, "ptr", pOutputType, "ptr*", pppMFTActivate, "uint*", pnumMFTActivate)
  351. loop % pnumMFTActivate
  352. {
  353. IMFActivate := NumGet(pppMFTActivate + (A_Index - 1)*A_PtrSize)
  354. if (A_Index = 1)
  355. hardware_encoder := IMFActivate_GetAllocatedString(IMFActivate, MF_GUID(GUID, "MFT_FRIENDLY_NAME_Attribute"))
  356. Release(IMFActivate)
  357. }
  358. DllCall("ole32\CoTaskMemFree", "ptr", pppMFTActivate)
  359. return hardware_encoder
  360. }
  361.  
  362. MFCreateSinkWriterFromURL(pwszOutputURL, pByteStream, pAttributes, ByRef ppSinkWriter)
  363. {
  364. hr := DllCall("Mfreadwrite.dll\MFCreateSinkWriterFromURL", "str", pwszOutputURL, "ptr", pByteStream, "ptr", pAttributes, "ptr*", ppSinkWriter)
  365. if hr or ErrorLevel
  366. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  367. }
  368.  
  369. MFCreateSourceReaderFromMediaSource(pMediaSource, pAttributes, ByRef ppSourceReader)
  370. {
  371. hr := DllCall("Mfreadwrite.dll\MFCreateSourceReaderFromMediaSource", "ptr", pMediaSource, "ptr", pAttributes, "ptr*", ppSourceReader)
  372. if hr or ErrorLevel
  373. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  374. }
  375.  
  376. MFCreateMediaType(ByRef ppMFType)
  377. {
  378. hr := DllCall("Mfplat.dll\MFCreateMediaType", "ptr*", ppMFType)
  379. if hr or ErrorLevel
  380. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  381. }
  382.  
  383. MFCreateAttributes(ByRef ppMFAttributes, cInitialSize)
  384. {
  385. hr := DllCall("Mfplat.dll\MFCreateAttributes", "ptr*", ppMFAttributes, "uint", cInitialSize)
  386. if hr or ErrorLevel
  387. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  388. }
  389.  
  390. MFCreateSample(ByRef ppIMFSample)
  391. {
  392. hr := DllCall("Mfplat.dll\MFCreateSample", "ptr*", ppIMFSample)
  393. if hr or ErrorLevel
  394. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  395. }
  396.  
  397. MFCreateMemoryBuffer(cbMaxLength, ByRef ppBuffer)
  398. {
  399. hr := DllCall("Mfplat.dll\MFCreateMemoryBuffer", "uint", cbMaxLength, "ptr*", ppBuffer)
  400. if hr or ErrorLevel
  401. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  402. }
  403.  
  404. MFCopyImage(pDest, lDestStride, pSrc, lSrcStride, dwWidthInBytes, dwLines)
  405. {
  406. hr := DllCall("Mfplat.dll\MFCopyImage", "ptr", pDest, "int", lDestStride, "ptr", pSrc, "int", lSrcStride, "uint", dwWidthInBytes, "uint", dwLines)
  407. if hr or ErrorLevel
  408. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  409. }
  410.  
  411. MFEnumDeviceSources(pAttributes, ByRef pppSourceActivate, ByRef pcSourceActivate)
  412. {
  413. hr := DllCall("Mf.dll\MFEnumDeviceSources", "ptr", pAttributes, "ptr*", pppSourceActivate, "uint*", pcSourceActivate)
  414. if hr or ErrorLevel
  415. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  416. }
  417.  
  418. MFCreateCollection(ByRef ppIMFCollection)
  419. {
  420. hr := DllCall("Mfplat.dll\MFCreateCollection", "ptr*", ppIMFCollection)
  421. if hr or ErrorLevel
  422. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  423. }
  424.  
  425. MFCreateAggregateSource(pSourceCollection, ByRef ppAggSource)
  426. {
  427. hr := DllCall("Mf.dll\MFCreateAggregateSource", "ptr", pSourceCollection, "ptr*", ppAggSource)
  428. if hr or ErrorLevel
  429. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  430. }
  431.  
  432. IMFSourceReader_SetCurrentMediaType(this, dwStreamIndex, pdwReserved, pMediaType)
  433. {
  434. hr := DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "uint", dwStreamIndex, "uint", pdwReserved, "ptr", pMediaType)
  435. if hr or ErrorLevel
  436. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  437. }
  438.  
  439. IMFSourceReader_SetStreamSelection(this, dwStreamIndex, fSelected)
  440. {
  441. hr := DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", dwStreamIndex, "int", fSelected)
  442. if hr or ErrorLevel
  443. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  444. }
  445.  
  446. IMFSourceReader_GetNativeMediaType(this, dwStreamIndex, dwMediaTypeIndex, ByRef ppMediaType)
  447. {
  448. hr := DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint", dwStreamIndex, "uint", dwMediaTypeIndex, "ptr*", ppMediaType)
  449. if hr or ErrorLevel
  450. {
  451. if (hr&=0xFFFFFFFF) = 0xC00D36B3 ; MF_E_INVALIDSTREAMNUMBER
  452. return "MF_E_INVALIDSTREAMNUMBER"
  453. if (hr&=0xFFFFFFFF) = 0xC00D36B9 ; MF_E_NO_MORE_TYPES
  454. return "MF_E_NO_MORE_TYPES"
  455. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  456. }
  457. }
  458.  
  459. IMFSourceReader_ReadSample(this, dwStreamIndex, dwControlFlags, ByRef pdwActualStreamIndex, ByRef pdwStreamFlags, ByRef pllTimestamp, ByRef ppSample)
  460. {
  461. hr := DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "uint", dwStreamIndex, "uint", dwControlFlags, "uint*", pdwActualStreamIndex, "uint*", pdwStreamFlags, "int64*", pllTimestamp, "ptr*", ppSample)
  462. if hr or ErrorLevel
  463. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  464. }
  465.  
  466. IMFAttributes_GetGUID(this, guidKey, ByRef pguidValue)
  467. {
  468. VarSetCapacity(pguidValue, 16, 0)
  469. hr := DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "ptr", guidKey, "ptr", &pguidValue)
  470. if hr or ErrorLevel
  471. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  472. return &pguidValue
  473. }
  474.  
  475. IMFAttributes_GetUINT64(this, guidKey, ByRef punValue)
  476. {
  477. hr := DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "ptr", guidKey, "uint64*", punValue)
  478. if hr or ErrorLevel
  479. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  480. }
  481.  
  482. IMFAttributes_GetUINT32(this, guidKey, ByRef punValue)
  483. {
  484. hr := DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "ptr", guidKey, "uint*", punValue)
  485. if hr or ErrorLevel
  486. {
  487. if (hr&=0xFFFFFFFF) = 0xC00D36E6 ; MF_E_ATTRIBUTENOTFOUND
  488. return "MF_E_ATTRIBUTENOTFOUND"
  489. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  490. }
  491. }
  492.  
  493. IMFAttributes_SetUINT32(this, guidKey, unValue)
  494. {
  495. hr := DllCall(NumGet(NumGet(this+0)+21*A_PtrSize), "ptr", this, "ptr", guidKey, "uint", unValue)
  496. if hr or ErrorLevel
  497. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  498. }
  499.  
  500. IMFAttributes_SetUINT64(this, guidKey, unValue)
  501. {
  502. hr := DllCall(NumGet(NumGet(this+0)+22*A_PtrSize), "ptr", this, "ptr", guidKey, "uint64", unValue)
  503. if hr or ErrorLevel
  504. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  505. }
  506.  
  507. IMFAttributes_SetGUID(this, guidKey, guidValue)
  508. {
  509. hr := DllCall(NumGet(NumGet(this+0)+24*A_PtrSize), "ptr", this, "ptr", guidKey, "ptr", guidValue)
  510. if hr or ErrorLevel
  511. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  512. }
  513.  
  514. IMFActivate_GetAllocatedString(this, guidKey)
  515. {
  516. hr := DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "ptr", guidKey, "ptr*", ppwszValue, "uint*", pcchLength)
  517. if hr or ErrorLevel
  518. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  519. AllocatedString := StrGet(ppwszValue, pcchLength, "UTF-16")
  520. DllCall("ole32\CoTaskMemFree", "ptr", ppwszValue)
  521. return AllocatedString
  522. }
  523.  
  524. IMFActivate_ActivateObject(this, riid, ByRef ppv)
  525. {
  526. GUID(riid, riid)
  527. hr := DllCall(NumGet(NumGet(this+0)+33*A_PtrSize), "ptr", this, "ptr", &riid, "ptr*", ppv)
  528. if hr or ErrorLevel
  529. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  530. }
  531.  
  532. IMFSinkWriter_SendStreamTick(this, dwStreamIndex, llTimestamp)
  533. {
  534. hr := DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "uint", dwStreamIndex, "int64", llTimestamp)
  535. if hr or ErrorLevel
  536. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  537. }
  538.  
  539. IMFSinkWriter_AddStream(this, pMediaTypeOut, ByRef pdwStreamIndex)
  540. {
  541. hr := DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr", pMediaTypeOut, "ptr*", pdwStreamIndex)
  542. if hr or ErrorLevel
  543. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  544. }
  545.  
  546. IMFSinkWriter_SetInputMediaType(this, dwStreamIndex, pInputMediaType, pEncodingParameters)
  547. {
  548. hr := DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", dwStreamIndex, "ptr", pInputMediaType, "ptr", pEncodingParameters)
  549. if hr or ErrorLevel
  550. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  551. }
  552.  
  553. IMFSinkWriter_BeginWriting(this)
  554. {
  555. hr := DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this)
  556. if hr or ErrorLevel
  557. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  558. }
  559.  
  560. IMFSinkWriter_WriteSample(this, dwStreamIndex, pSample)
  561. {
  562. hr := DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint", dwStreamIndex, "ptr", pSample)
  563. if hr or ErrorLevel
  564. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  565. }
  566.  
  567. IMFSinkWriter_Finalize(this)
  568. {
  569. hr := DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this)
  570. if hr or ErrorLevel
  571. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  572. }
  573.  
  574. IMFMediaBuffer_Lock(this, ByRef ppbBuffer, ByRef pcbMaxLength, ByRef pcbCurrentLength)
  575. {
  576. hr := DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr*", ppbBuffer, "uint*", pcbMaxLength, "uint*", pcbCurrentLength)
  577. if hr or ErrorLevel
  578. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  579. }
  580.  
  581. IMFMediaBuffer_Unlock(this)
  582. {
  583. hr := DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this)
  584. if hr or ErrorLevel
  585. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  586. }
  587.  
  588. IMFMediaBuffer_SetCurrentLength(this, cbCurrentLength)
  589. {
  590. hr := DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint", cbCurrentLength)
  591. if hr or ErrorLevel
  592. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  593. }
  594.  
  595. IMFMediaSource_Shutdown(this)
  596. {
  597. hr := DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this)
  598. if hr or ErrorLevel
  599. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  600. }
  601.  
  602. IMFSample_AddBuffer(this, pBuffer)
  603. {
  604. hr := DllCall(NumGet(NumGet(this+0)+42*A_PtrSize), "ptr", this, "ptr", pBuffer)
  605. if hr or ErrorLevel
  606. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  607. }
  608.  
  609. IMFSample_SetSampleTime(this, hnsSampleTime)
  610. {
  611. hr := DllCall(NumGet(NumGet(this+0)+36*A_PtrSize), "ptr", this, "int64", hnsSampleTime)
  612. if hr or ErrorLevel
  613. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  614. }
  615.  
  616. IMFSample_GetSampleDuration(this, ByRef phnsSampleDuration)
  617. {
  618. hr := DllCall(NumGet(NumGet(this+0)+37*A_PtrSize), "ptr", this, "int64*", phnsSampleDuration)
  619. if hr or ErrorLevel
  620. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  621. }
  622.  
  623. IMFSample_SetSampleDuration(this, hnsSampleDuration)
  624. {
  625. hr := DllCall(NumGet(NumGet(this+0)+38*A_PtrSize), "ptr", this, "int64", hnsSampleDuration)
  626. if hr or ErrorLevel
  627. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  628. }
  629.  
  630. IMFCollection_AddElement(this, pUnkElement)
  631. {
  632. hr := DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "ptr", pUnkElement)
  633. if hr or ErrorLevel
  634. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  635. }
  636.  
  637. MF_GUID(ByRef GUID, name)
  638. {
  639. static init:=1, _:={}
  640. if init
  641. {
  642. init:=0
  643. _.MF_MT_MAJOR_TYPE := [0x48eba18e, 0xf8c9, 0x4687, 0xbf, 0x11, 0x0a, 0x74, 0xc9, 0xf9, 0x6a, 0x8f]
  644. _.MF_MT_SUBTYPE := [0xf7e34c9a, 0x42e8, 0x4714, 0xb7, 0x4b, 0xcb, 0x29, 0xd7, 0x2c, 0x35, 0xe5]
  645. _.MF_MT_AVG_BITRATE := [0x20332624, 0xfb0d, 0x4d9e, 0xbd, 0x0d, 0xcb, 0xf6, 0x78, 0x6c, 0x10, 0x2e]
  646. _.MF_MT_INTERLACE_MODE := [0xe2724bb8, 0xe676, 0x4806, 0xb4, 0xb2, 0xa8, 0xd6, 0xef, 0xb4, 0x4c, 0xcd]
  647. _.MF_MT_FRAME_SIZE := [0x1652c33d, 0xd6b2, 0x4012, 0xb8, 0x34, 0x72, 0x03, 0x08, 0x49, 0xa3, 0x7d]
  648. _.MF_MT_FRAME_RATE := [0xc459a2e8, 0x3d2c, 0x4e44, 0xb1, 0x32, 0xfe, 0xe5, 0x15, 0x6c, 0x7b, 0xb0]
  649. _.MF_MT_PIXEL_ASPECT_RATIO := [0xc6376a1e, 0x8d0a, 0x4027, 0xbe, 0x45, 0x6d, 0x9a, 0x0a, 0xd3, 0x9b, 0xb6]
  650. _.MF_MT_AUDIO_AVG_BYTES_PER_SECOND := [0x1aab75c8, 0xcfef, 0x451c, 0xab, 0x95, 0xac, 0x03, 0x4b, 0x8e, 0x17, 0x31]
  651. _.MF_MT_AUDIO_BLOCK_ALIGNMENT := [0x322de230, 0x9eeb, 0x43bd, 0xab, 0x7a, 0xff, 0x41, 0x22, 0x51, 0x54, 0x1d]
  652. _.MF_MT_AUDIO_SAMPLES_PER_SECOND := [0x5faeeae7, 0x0290, 0x4c31, 0x9e, 0x8a, 0xc5, 0x34, 0xf6, 0x8d, 0x9d, 0xba]
  653. _.MF_MT_AUDIO_BITS_PER_SAMPLE := [0xf2deb57f, 0x40fa, 0x4764, 0xaa, 0x33, 0xed, 0x4f, 0x2d, 0x1f, 0xf6, 0x69]
  654. _.MF_MT_AUDIO_NUM_CHANNELS := [0x37e48bf5, 0x645e, 0x4c5b, 0x89, 0xde, 0xad, 0xa9, 0xe2, 0x9b, 0x69, 0x6a]
  655. _.MFT_CATEGORY_VIDEO_ENCODER := [0xf79eac7d, 0xe545, 0x4387, 0xbd, 0xee, 0xd6, 0x47, 0xd7, 0xbd, 0xe4, 0x2a]
  656. _.MF_TRANSCODE_CONTAINERTYPE := [0x150ff23f, 0x4abc, 0x478b, 0xac, 0x4f, 0xe1, 0x91, 0x6f, 0xba, 0x1c, 0xca]
  657. _.MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS := [0xa634a91c, 0x822b, 0x41b9, 0xa4, 0x94, 0x4d, 0xe4, 0x64, 0x36, 0x12, 0xb0]
  658. _.MFTranscodeContainerType_MPEG4 := [0xdc6cd05d, 0xb9d0, 0x40ef, 0xbd, 0x35, 0xfa, 0x62, 0x2c, 0x1a, 0xb2, 0x8a]
  659. _.MFT_FRIENDLY_NAME_Attribute := [0x314ffbae, 0x5b41, 0x4c95, 0x9c, 0x19, 0x4e, 0x7d, 0x58, 0x6f, 0xac, 0xe3]
  660. _.MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME := [0x60d0e559, 0x52f8, 0x4fa2, 0xbb, 0xce, 0xac, 0xdb, 0x34, 0xa8, 0xec, 0x1]
  661. _.MF_SINK_WRITER_DISABLE_THROTTLING := [0x08b845d8, 0x2b74, 0x4afe, 0x9d, 0x53, 0xbe, 0x16, 0xd2, 0xd5, 0xae, 0x4f]
  662. _.MF_LOW_LATENCY := [0x9c27891a, 0xed7a, 0x40e1, 0x88, 0xe8, 0xb2, 0x27, 0x27, 0xa0, 0x24, 0xee]
  663. _.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE := [0xc60ac5fe, 0x252a, 0x478f, 0xa0, 0xef, 0xbc, 0x8f, 0xa5, 0xf7, 0xca, 0xd3]
  664. _.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID := [0x14dd9a1c, 0x7cff, 0x41be, 0xb1, 0xb9, 0xba, 0x1a, 0xc6, 0xec, 0xb5, 0x71]
  665. _.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID := [0x8ac3587a, 0x4ae7, 0x42d8, 0x99, 0xe0, 0x0a, 0x60, 0x13, 0xee, 0xf9, 0x0f]
  666. _.MF_SOURCE_READER_DISCONNECT_MEDIASOURCE_ON_SHUTDOWN := [0x56b67165, 0x219e, 0x456d, 0xa2, 0x2e, 0x2d, 0x30, 0x04, 0xc7, 0xfe, 0x56]
  667. _.MFSampleExtension_Discontinuity := [0x9cdf01d9, 0xa0f0, 0x43ba, 0xb0, 0x77, 0xea, 0xa0, 0x6c, 0xbd, 0x72, 0x8a]
  668. _.MFMediaType_Video := [0x73646976, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  669. _.MFMediaType_Audio := [0x73647561, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71]
  670. _.MFAudioFormat_AAC := [0x1610, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  671. _.MFAudioFormat_Float := [0x0003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  672. _.MFAudioFormat_PCM := [0x0001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  673. _.MFVideoFormat_H264 := [0x34363248, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71] ; FCC("H264") = 0x34363248
  674. _.MFVideoFormat_RGB32 := [0x00000016, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  675. _.MFVideoFormat_ARGB32 := [0x00000015, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  676. _.MFVideoFormat_I420 := [0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  677. _.MFVideoFormat_IYUV := [0x56555949, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  678. _.MFVideoFormat_NV12 := [0x3231564E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  679. _.MFVideoFormat_YUY2 := [0x32595559, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  680. _.MFVideoFormat_YV12 := [0x32315659, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71]
  681.  
  682. }
  683. if _.haskey(name)
  684. {
  685. p := _[name]
  686. VarSetCapacity(GUID,16)
  687. ,NumPut(p.1+(p.2<<32)+(p.3<<48),GUID,0,"int64")
  688. ,NumPut(p.4+(p.5<<8)+(p.6<<16)+(p.7<<24)+(p.8<<32)+(p.9<<40)+(p.10<<48)+(p.11<<56),GUID,8,"int64")
  689. return &GUID
  690. }
  691. else return name
  692. }
  693.  
  694. GUID(ByRef GUID, sGUID)
  695. {
  696. VarSetCapacity(GUID, 16, 0)
  697. return DllCall("ole32\CLSIDFromString", "WStr", sGUID, "Ptr", &GUID) >= 0 ? &GUID : ""
  698. }
  699.  
  700. FCC(var)
  701. {
  702. c := StrSplit(var)
  703. msgbox % clipboard := Format("{:#x}",((Asc(c[1])&255)+((Asc(c[2])&255)<<8)+((Asc(c[3])&255)<<16)+((Asc(c[4])&255)<<24)))
  704. }
  705.  
  706. Release(this)
  707. {
  708. DllCall(NumGet(NumGet(this+0)+2*A_PtrSize), "ptr", this)
  709. if ErrorLevel
  710. _Error(A_ThisFunc " error: " hr "`nErrorLevel: " ErrorLevel)
  711. }
  712.  
  713. MemoryDifference(ptr1, ptr2, num)
  714. {
  715. return DllCall("msvcrt\memcmp", "ptr", ptr1, "ptr", ptr2, "int", num)
  716. }
  717.  
  718. _Error(val)
  719. {
  720. msgbox % val
  721. ExitApp
  722. }
RAW Paste Data