Jump to content

Belini

Active Members
  • Posts

    906
  • Joined

  • Last visited

  • Days Won

    2

Belini last won the day on August 12 2012

Belini had the most liked content!

2 Followers

About Belini

  • Birthday 08/25/1968

Profile Information

  • Member Title
    Always seeking knowledge
  • Location
    Brazil
  • Interests
    Acquiring knowledge and pass on autoit.

Recent Profile Visitors

1,099 profile views

Belini's Achievements

  1. @CYCho the quotation marks really solve the problem, but if you use FileGetShortName() even placing quotation marks does not work in this version of winmm.dll which caused the problem.
  2. I found the cause of the problem, it doesn't work if you use quotation marks if you are using FileGetShortName() and in the end using quotation marks was the solution but it has to be in the full path and not in the shortest path. $iRet = _mciSendString("open " & FileGetShortName($sFile) & " alias " & $sVID & $sDT); Does not work ; exchanged for $iRet = _mciSendString("open " & '"' & $sFile & '"' & " alias " & $sVID & $sDT); now everything works Thanks @Andreik and @Gianni for trying to help EDITED: I think it has to do with the version of Winmm.dll because I always used FileGetShortName() and it always worked and I never needed to use quotes for it to work but in this version it only works with quotes in the full path and without using FileGetShortName()
  3. @Andreik just putting quotes I had already tried and it didn't work @Gianni using FileGetShortName() I had also tried and it didn't work
  4. I can't play videos using winmm.dll if there is space in the directory path and I can't solve this, in the research I did I found people with the same problem and the solution they gave was to put the path in quotes but in Autoit it didn't work, is there anything Another way to pass paths with space to the _mciSendString() function that works in Autoit? Similar problem to mine: https://stackoverflow.com/questions/1148022/mcisendstring-cannot-save-to-directory-path My attempts: Func _Video_Open($sFile, $hWnd, $iX, $iY, $iH, $iW, $sDevice = "") Local $sVID, $gId, $iRet, $sDT = "" ;$sFile = '"' & $sFile & '"' ; <============================ It didn't work with space in the name ;$sFile = chr(32) & $sFile & chr(32) ; <===================== It didn't work with space in the name ;I need another way to pass the path with space to open the videos ; <============================ My problem If Not FileExists($sFile) Then Return SetError(1, 0, "") If Not IsHWnd($hWnd) Then Return SetError(2, 0, "") If $sDevice <> "" Then If Not _mciDeviceExists($sDevice) Then Return SetError(3, 0, "") $sDT = " type " & $sDevice EndIf $gId = Dec(StringTrimLeft($hWnd, 2)) $sVID = _RandomStr() $iRet = _mciSendString("open " & FileGetShortName($sFile) & " alias " & $sVID & $sDT) If $iRet <> 0 Then Return SetError(4, 0, "") $iRet = _mciSendString("window " & $sVID & " handle " & $gId) If $iRet <> 0 Then _mciSendString("close " & $sVID) Return SetError(5, 0, "") EndIf $iRet = _mciSendString("put " & $sVID & " destination at " & $iX & " " & $iY & " " & $iH & " " & $iW) If $iRet <> 0 Then _mciSendString("close " & $sVID) Return SetError(6, 0, "") EndIf Return SetError(0, 0, $sVID) EndFunc ;==>_Video_Open Func _mciSendString($string, $iLen = 0) Local $iRet $iRet = DllCall("winmm.dll", "int", "mciSendStringA", "str", $string, "str", "", "long", $iLen, "long", 0) If Not @error Then Return $iRet[2] EndFunc ;==>_mciSendString
  5. I tested it here with some changes and found it interesting #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> global $_label, $Form1 $Form1 = GUICreate("Form1", 400, 150, -1, -1) _CreateLabel("TESTE", 40, 50, 640, 50, Default, Default, 0X00FF00, "Arial", 30) _SetLabelData($_label, "TESTANDO") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _CreateLabel($_text, $_x, $_y, $_w = Default, $_h = Default, $_style = Default, $_fgcol = Default, $_bkcol = 0, $ft_type = "Arial", $ft_size = 12) Local $_d[4][2] = [[0, -1], [0, 1], [-1, 0], [1, 0]] For $_z = 0 To 3 GUICtrlCreateLabel($_text, $_x + $_d[$_z][0], $_y + $_d[$_z][1], $_w, $_h, $_style) GUICtrlSetFont(-1, $ft_size, 400, 4, $ft_type) GUICtrlSetColor(-1, $_bkcol) GUICtrlSetBkColor(-1, -2) Next $_label = GUICtrlCreateLabel($_text, $_x, $_y, $_w, $_h, $_style) GUICtrlSetFont(-1, $ft_size, 400, 4, $ft_type) GUICtrlSetColor(-1, $_fgcol) GUICtrlSetBkColor(-1, -2) Return $_label EndFunc Func _SetLabelData($_handle, $_data) For $_z = 0 To 4 GUICtrlSetData($_handle - $_z, $_data) Next EndFunc
  6. I love Libre-Oficce and this UDF will certainly be very useful!
  7. I particularly use MediaInfo.dll to get the data I need from audio and video files and it works well for me with all audio and video extensions.
  8. So your video was already made with black stripes, send me the video so I can check it out here.
  9. To get a full screen in VLC you will first need to find out the aspect ratio of your desktop and send it to VLC via the command line when you open it, and I created a function to find out the aspect ratio of the desktop. Global $oHttpObj = ObjCreate("winhttp.winhttprequest.5.1"); cria a janela do navegador para receber os comandos $ratio_maq = Preenche_Tela(@DesktopWidth, @DesktopHeight); pega o aspect ratio da tela $pid_vlc = Run('"' & @ScriptDir & '\vlc.exe"' & " --aspect-ratio=" & $ratio_maq & " --video-title=Video:9999 --fullscreen --video-x=1 --video-y=1 -Idummy --extraint=http --http-host=127.0.0.1 --http-port=9999 --http-password=0000", @ScriptDir, @SW_HIDE); executa o vlc _Video_play(@ScriptDir & '\Produce.mp4'); toca o vídeo escolhido em tela cheia Func Preenche_Tela($resol_w, $resol_h) Local $GCD, $ASP_RAT, $GUARD, $INT[3] $INT[1] = $resol_w $INT[2] = $resol_h For $i = $INT[1] To 1 Step -1 If Mod($INT[1], $i) = 0 Then $GUARD &= "|" & $i & "|" Next For $i = $INT[2] To 1 Step -1 If Mod($INT[2], $i) = 0 Then If StringInStr($GUARD, "|" & $i & "|") Then $GCD = $i ExitLoop EndIf EndIf Next $ASP_RAT = ($INT[1] / $GCD) & ":" & ($INT[2] / $GCD) Return $ASP_RAT EndFunc ;==>Preenche_Tela Func _Video_play($video = "") Local $comando = "http://127.0.0.1:9999/requests/status.xml?command=in_enqueue&input=" & $video; coloca o arquivo na lista $oHttpObj.open("GET", $comando, False) $oHttpObj.SetRequestHeader("Authorization", "Basic OjAwMDA=0000") $oHttpObj.Send(); executa o vlc identificando a janela $comando = "http://127.0.0.1:9999/requests/status.xml?command=pl_play" $oHttpObj.open("GET", $comando, False) $oHttpObj.SetRequestHeader("Authorization", "Basic OjAwMDA=0000") $oHttpObj.Send() WinWait("Video:9999", "", 5) WinSetOnTop("Video:9999", "", 1) EndFunc ;==>_Video_play
  10. @CYCho this is how the 1024 x 786 video is shown in a resolution of 1600 x 900 using wimm.dll but there are players that have the option to stretch to fill the entire screen without getting those black stripes on the sides or top and lower, for example winamp and vlc.
  11. I tested it on Windows 7 and it gets black stripes on the sides if the video resolution is not equal or proportional to the desktop resolution.
  12. Thanks @CYCho I'll test it here to see if it works on mine too EDITED: I tested it here and it doesn't work, your script only maximizes the window but doesn't make the video fill the entire screen and it still has black stripes when the video isn't the same resolution as the desktop
  13. The computer I tested is about 5 years old. the codec I used was "Xvid MPEG-4" which creates smaller files. I put everything together in a script, just the UDF made by Frank10 and the other one that you changed to make it easier to compare and thus try to remove the errors that occurred in the UDF that you changed.
  14. I tested with the _WebcamDS_SaveFile() function that @mLipok changed and I kept the rest done by @frank10 and the recording worked, but sometimes the audio and video are out of sync. UDF made by Frank10 with changes made to SaveFile() by mLipok (Recording working) #include <Misc.au3> #include <WinAPI.au3> #include <GuiComboBox.au3> #include <SendMessage.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; ========================================================================================================================= VARIABLES Global $AudioPrevBox, $AudioCapBox, $FrameInput, $SaveButton, $StopButton, $ZoomButton, $FullButton Global $hComboCam = '', $hComboComp = '', $hComboMic, $ZoomInput = '' Global $aWebcamList[9] Global $aCompressorList[50] Global $aMicList[9] Global $iWebcam = 1, $iWebAudio = 0, $iWebRescale = 1, $iWebX, $iWebY, $iWebBpp, $aZoomPos[4] Global $oBasicAudio, $oBasicVideo, $oBuild, $oCapture[9], $oCaptureAudio, $oGraph, $oIBaseFilter, $oMediaControl, $oDevEnum, $oEnum, $oICreateDevEnum, $oIEnumMoniker Global $oVideoWindow, $oVmr9, $oCompressor, $oStreamConfig Global $Vmr9 = 1, $iWebXinside = 0, $iWebYinside = 0 Global Const $CompressionCaps_CanKeyFrame = 0x04 Global Const $sIID_IMediaControl = '{56A868B1-0AD4-11CE-B03A-0020AF0BA770}' Global Const $sCLSID_VideoInputDeviceCategory = '{860bb310-5d01-11d0-bd3b-00a0c911ce86}' Global Const $sCLSID_AudioInputDeviceCategory = '{33d9a762-90c8-11d0-bd43-00a0c911ce86}' Global Const $sCLSID_VideoCompressorCategory = '{33d9a760-90c8-11d0-bd43-00a0c911ce86}' Global Const $S_OK = 0 Global Const $PIN_CATEGORY_CAPTURE = '{fb6c4281-0353-11d1-905f-0000c0cc16ba}' Global Const $PIN_CATEGORY_PREVIEW = '{fb6c4282-0353-11d1-905f-0000c0cc16ba}' Global Const $MEDIASUBTYPE_Avi = '{e436eb88-524f-11ce-9f53-0020af0ba770}' Global Const $MEDIATYPE_Video = '{73646976-0000-0010-8000-00aa00389b71}' Global Const $MEDIATYPE_Audio = '{73647561-0000-0010-8000-00aa00389b71}' Global Const $sCLSID_VideoMixingRenderer9 = '{51b4abf3-748f-4e3b-a276-c828330e926a}' Global Const $sCLSID_FilterGraph = "{E436EBB3-524F-11CE-9F53-0020AF0BA770}" Global Const $sIID_IGraphBuilder = "{56A868A9-0AD4-11CE-B03A-0020AF0BA770}" Global Const $tagIGraphBuilder = "AddFilter hresult(ptr;wstr);" & "RemoveFilter hresult(ptr);" & "EnumFilters hresult(ptr*);" & "FindFilterByName hresult(wstr;ptr*);" & "ConnectDirect hresult(ptr;ptr;ptr);" & "Reconnect hresult(ptr);" & "Disconnect hresult(ptr);" & "SetDefaultSyncSource hresult();" & "Connect hresult(ptr;ptr);" & "Render hresult(ptr);" & "RenderFile hresult(wstr;ptr);" & "AddSourceFilter hresult(wstr;wstr;ptr*);" & "SetLogFile hresult(dword_ptr);" & "Abort hresult();" & "ShouldOperationContinue hresult();" Global Const $sCLSID_CaptureGraphBuilder2 = '{BF87B6E1-8C27-11D0-B3F0-00AA003761C5}' Global Const $sIID_ICaptureGraphBuilder2 = '{93e5a4e0-2d50-11d2-abfa-00a0c9c6e38d}' Global Const $tagICaptureGraphBuilder2 = "SetFiltergraph hresult(ptr);" & "GetFiltergraph hresult(ptr*);" & "SetOutputFileName hresult(clsid;wstr;ptr*;ptr*);" & "FindInterface hresult(clsid;clsid;ptr;clsid;ptr*);" & "RenderStream hresult(clsid;clsid;ptr;ptr;ptr);" & "ControlStream hresult(clsid;clsid;ptr;ptr;ptr;word;word);" & "AllocCapFile hresult(wstr;int64);" & "CopyCaptureFile hresult(wstr;wstr;int;ptr*);" & "FindPin hresult(ptr;int;clsid;clsid;bool;int;ptr*);" Global Const $sCLSID_SystemDeviceEnum = '{62BE5D10-60EB-11d0-BD3B-00A0C911CE86}' Global Const $sIID_ICreateDevEnum = '{29840822-5b84-11d0-bd3b-00a0c911ce86}' Global Const $tagICreateDevEnum = "CreateClassEnumerator hresult( clsid ; ptr*; dword );" Global Const $sIID_IEnumMoniker = '{00000102-0000-0000-c000-000000000046}' Global Const $tagIEnumMoniker = "Next hresult(dword;ptr*;dword*);" & "Skip hresult(dword);" & "Reset hresult();" & "Clone hresult(ptr*);" Global Const $sIID_IBaseFilter = '{56a86895-0ad4-11ce-b03a-0020af0ba770}' Global Const $tagIBaseFilter = "GetClassID hresult(ptr*);" & "Stop hresult();" & "Pause hresult();" & "Run hresult(int64);" & "GetState hresult(dword;dword*);" & "SetSyncSource hresult(ptr);" & "GetSyncSource hresult(ptr*);" & "EnumPins hresult(ptr*);" & "FindPin hresult(wstr;ptr*);" & "QueryFilterInfo hresult(ptr*);" & "JoinFilterGraph hresult(ptr;wstr);" & "QueryVendorInfo hresult(wstr*);" Global Const $sIID_IMoniker = '{0000000f-0000-0000-C000-000000000046}' Global Const $tagIMoniker = "GetClassID hresult( clsid )" & "IsDirty hresult( );" & "Load hresult( ptr );" & "Save hresult( ptr, bool );" & "GetSizeMax hresult( uint64 );" & "BindToObject hresult( ptr;ptr;clsid;ptr*);" & "BindToStorage hresult( ptr;ptr;clsid;ptr*);" & "Reduce hresult( ptr;dword;ptr*;ptr*);" & "ComposeWith hresult( ptr;bool;ptr*);" & "Enum hresult( bool;ptr*);" & "IsEqual hresult( ptr);" & "Hash hresult( dword*);" & "IsRunning hresult( ptr;ptr;ptr);" & "GetTimeOfLastChange hresult( ptr;ptr;int64*);" & "Inverse hresult( ptr*);" & "CommonPrefixWith hresult( ptr;ptr*);" & "RelativePathTo hresult( ptr;ptr*);" & "GetDisplayName hresult( ptr;ptr;wstr*);" & "ParseDisplayName hresult( ptr;ptr;wstr;ulong*;ptr*);" & "IsSystemMoniker hresult( dword*);" Global Const $tagIDispatch = "GetTypeInfoCount hresult(dword*);" & "GetTypeInfo hresult(dword;dword;ptr*);" & "GetIDsOfNames hresult(clsid;ptr;dword;dword;ptr);" & "Invoke hresult(dword;clsid;dword;word;ptr;ptr;ptr;dword*);" Global Const $sIID_IVideoWindow = "{56A868B4-0AD4-11CE-B03A-0020AF0BA770}" Global Const $tagIVideoWindow = $tagIDispatch & "put_Caption hresult(bstr);" & "get_Caption hresult(bstr*);" & "put_WindowStyle hresult(long);" & "get_WindowStyle hresult(long*);" & "put_WindowStyleEx hresult(long);" & "put_WindowStyleEx hresult(long*);" & "put_AutoShow hresult(long);" & "get_AutoShow hresult(long*);" & "put_WindowState hresult(long);" & "get_WindowState hresult(long*);" & "put_BackgroundPalette hresult(long);" & "get_BackgroundPalette hresult(long*);" & "put_Visible hresult(long);" & "get_Visible hresult(long*);" & "put_Left hresult(long);" & "get_Left hresult(long*);" & "put_Width hresult(long);" & "get_Width hresult(long*);" & "put_Top hresult(long);" & "get_Top hresult(long*);" & "put_Height hresult(long);" & "get_Height hresult(long*);" & "put_Owner hresult(long_ptr);" & "get_Owner hresult(long_ptr*);" & "put_MessageDrain hresult(long_ptr);" & "get_MessageDrain hresult(long_ptr*);" & "get_BorderColor hresult(long*);" & "put_BorderColor hresult(long);" & "get_FullScreenMode hresult(long*);" & "put_FullScreenMode hresult(long);" & "SetWindowForeground hresult(long);" & "NotifyOwnerMessage hresult(long_ptr;long;long_ptr;long_ptr);" & "SetWindowPosition hresult(long;long;long;long);" & "GetWindowPosition hresult(long*;long*;long*;long*);" & "GetMinIdealImageSize hresult(long*;long*);" & "GetMaxIdealImageSize hresult(long*;long*);" & "GetRestorePosition hresult(long*;long*;long*;long*);" & "HideCursor hresult(long);" & "IsCursorHidden hresult(long*);" Global Const $sIID_IBasicVideo = "{56A868B5-0AD4-11CE-B03A-0020AF0BA770}" Global Const $tagIBasicVideo = $tagIDispatch & "get_AvgTimePerFrame hresult(double*);" & "get_BitRate hresult(long*);" & "get_BitErrorRate hresult(long*);" & "get_VideoWidth hresult(long*);" & "get_VideoHeight hresult(long*);" & "put_SourceLeft hresult(long);" & "get_SourceLeft hresult(long*);" & "put_SourceWidth hresult(long);" & "get_SourceWidth hresult(long*);" & "put_SourceTop hresult(long);" & "get_SourceTop hresult(long*);" & "put_SourceHeight hresult(long);" & "get_SourceHeight hresult(long*);" & "put_DestinationLeft hresult(long);" & "get_DestinationLeft hresult(long*);" & "put_DestinationWidth hresult(long);" & "get_DestinationWidth hresult(long*);" & "put_DestinationTop hresult(long);" & "get_DestinationTop hresult(long*);" & "put_DestinationHeight hresult(long);" & "get_DestinationHeight hresult(long*);" & "SetSourcePosition hresult(long;long;long;long);" & "GetSourcePosition hresult(long*;long*;long*;long*);" & "SetDefaultSourcePosition hresult();" & "SetDestinationPosition hresult(long;long;long;long);" & "GetDestinationPosition hresult(long*;long*;long*;long*);" & "SetDefaultDestinationPosition hresult();" & "GetVideoSize hresult(long*;long*);" & "GetVideoPaletteEntries hresult(long;long;long*;long*);" & "GetCurrentImage hresult(long*;long*);" & "IsUsingDefaultSource hresult();" & "IsUsingDefaultDestination hresult();" Global Const $sIID_IPropertyBag = '{55272a00-42cb-11ce-8135-00aa004bb851}' Global Const $tagIPropertyBag = 'Read hresult(wstr;variant*;ptr*);' & 'Write hresult(wstr;variant);' Global Const $tagIVMRWindowlessControl = 'GetNativeVideoSize hresult(long*;long*;long*;long*);' & 'GetMinIdealVideoSize hresult(long*;long*);' & 'GetMaxIdealVideoSize hresult(long*;long*);' & 'SetVideoPosition hresult(ptr;ptr);' & 'GetVideoPosition hresult(ptr*;ptr*);' & 'GetAspectRatioMode hresult(dword*);' & 'SetAspectRatioMode hresult(dword);' & 'SetVideoClippingWindow hresult(hwnd);' & 'RepaintVideo hresult(hwnd;handle);' & 'DisplayModeChanged hresult();' & 'GetCurrentImage hresult(byte*);' & 'SetBorderColor hresult(clr);' & 'GetBorderColor hresult(clr*);' & 'SetColorKey hresult(clr);' & 'GetColorKey hresult(clr*);' Global Const $tagIVMRFilterConfig = 'SetImageCompositor hresult(ptr);' & 'GetNumberOfStreams hresult(dword*);' & 'SetRenderingPrefs hresult(dword);' & 'GetRenderingPrefs hresult(dword*);' & 'SetRenderingMode hresult(dword);' & 'GetrenderingMode hresult(dword*);' Global Const $sIID_IVMRFilterConfig9 = '{5a804648-4f66-4867-9c43-4f5c822cf1b8}' Global Const $tagIVMRFilterConfig9 = 'SetImageCompositor hresult(ptr);' & 'SetNumberOfStreams hresult(dword);' & 'GetNumberOfStreams hresult(dword*);' & 'SetRenderingPrefs hresult(dword);' & 'GetRenderingPrefs hresult(dword*);' & 'SetRenderingMode hresult(dword);' & 'GetrenderingMode hresult(dword*);' Global Const $sIID_IVMRMixerControl9 = '{1a777eaa-47c8-4930-b2c9-8fee1c1b0f3b}' Global Const $tagIVMRMixerControl9 = 'SetAlpha(dword;float);' & 'GetAlpha(dword;ptr*) ;' & 'SetZOrder(dword;dword) ;' & 'GetZOrder(dword;ptr*) ;' & 'SetOutputRect(dword;ptr) ;' & 'GetOutputRect(dword;ptr*) ;' & 'SetBackgroundClr(dword) ;' & 'GetBackgroundClr(ptr) ;' & 'SetMixingPrefs(dword) ;' & 'GetMixingPrefs(ptr*) ;' & 'SetProcAmpControl(dword;ptr) ;' & 'GetProcAmpControl(dword;ptr*) ;' & 'GetProcAmpControlRange(dword;ptr*);' Global Const $sIID_IAMStreamConfig = '{c6e13340-30ac-11d0-a18c-00a0c9118956}' Global Const $tagIAMStreamConfig = 'SetFormat hresult(ptr);' & 'GetFormat hresult(ptr*);' & 'GetNumberOfCapabilities hresult(int*;int*);' & 'GetStreamCaps hresult(int;ptr*;struct*);' Global Const $sIID_IAMVideoCompression = '{c6e13343-30ac-11d0-a18c-00a0c9118956}' Global Const $tagIAMVideoCompression = 'put_KeyFrameRate hresult(int);' & 'get_KeyFrameRate hresult(int*);' & 'put_PFramesPerKeyFrame hresult(int);' & 'get_PFramesPerKeyFrame hresult(int*);' & 'put_Quality hresult(double);' & 'get_Quality hresult(double*);' & 'put_WindowSize hresult();' & 'get_WindowSize hresult(uint64*);' & 'getInfo hresult(ptr*;int;ptr*;int*;int*;int*;double*;int*);' & 'OverrideKeyFrame hresult(int);' & 'OverrideFrameSize hresult(int;int);' Global Const $sIID_IEnumPins = '{56a86892-0ad4-11ce-b03a-0020af0ba770}' Global Const $tagIEnumPins = 'Next hresult(dword;ptr*;dword*);' & 'Skip hresult(dword);' & 'Reset hresult();' & 'Clone hresult(ptr*);' Global Const $sIID_IPin = '{56a86891-0ad4-11ce-b03a-0020af0ba770}' Global Const $tagIPin = 'Connect hresult(ptr;ptr);' & 'ReceiveConnection hresult(ptr;ptr);' & 'Disconnect hresult();' & 'ConnectedTo hresult(ptr*);' & "ConnectionMediaType hresult(ptr*);" & "QueryPinInfo hresult(ptr*);" & "QueryDirection hresult(int*);" & "QueryId hresult(wstr*);" & "QueryAccept hresult(ptr);" & "EnumMediaTypes hresult(ptr*);" & "QueryInternalConnections hresult(ptr*;dword*);" & "EndOfStream hresult();" & "BeginFlush hresult();" & "EndFlush hresult();" & "NewSegment hresult(int64;int64;double);" Global Const $tagIAMAudioInputMixer = 'put_Enable hresult(bool);' & 'get_Enable hresult(bool*);' & 'put_Mono hresult(bool);' & 'get_Mono hresult(bool*);' & 'put_MixLevel hresult(double);' & 'get_MixLevel hresult(double*);' & 'put_Pan hresult(double);' & 'get_Pan hresult(double*);' & 'put_Loudness hresult(bool);' & 'get_Loudness hresult(bool*);' & 'put_Treble hresult(double);' & 'get_Treble hresult(double*);' & 'get_TrebleRange hresult(double*);' & 'put_Bass hresult(double);' & 'get_Bass hresult(double*);' & 'get_BassRange hresult(double*);' $aZoomPos[0] = 1 $aZoomPos[1] = 0 $aZoomPos[2] = 1 $aZoomPos[3] = 0 ; ========================================================================================================================= VARIABLES ; =========================================================================================================================== EXAMPLE Global $UserDLL = DllOpen("user32.dll") Global $hGUI = GUICreate("DirectShow Capture", 1280, 720, -1, -1, -1) Opt("MustDeclareVars", 1) OnAutoItExitRegister("_onExit") Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") $iWebXinside = 0 $iWebYinside = 26 _WebcamDS_Init() If @error <> 0 Or @extended <> 0 Then Exit _CreateGui() _WebcamDS_RenderWebcam(1, 0, $hGUI, 0, 640, 480, 16) If @error <> 0 Or @extended <> 0 Then Exit If $iWebAudio <> 0 And GUICtrlRead($AudioPrevBox) = $GUI_UNCHECKED Then GUICtrlSetState($AudioPrevBox, $GUI_CHECKED) Global $msg While 1 $msg = GUIGetMsg() Select Case $msg = $SaveButton Local $audio = 0, $comp If GUICtrlRead($AudioCapBox) = $GUI_CHECKED Then $audio = _GUICtrlComboBox_GetCurSel($hComboMic) + 1 $comp = GUICtrlRead($hComboComp) _WebcamDS_SaveFile(@ScriptDir & '\test.avi', $comp, $audio) Case $msg = $StopButton _WebcamDS_Reset() _WebcamDS_RenderWebcam($iWebcam, $iWebAudio, $hGUI, $iWebRescale, $iWebX, $iWebY, 16) Case $msg = $hComboMic If GUICtrlRead($AudioPrevBox) = $GUI_CHECKED Then $iWebAudio = _GUICtrlComboBox_GetCurSel($hComboMic) + 1 If $iWebAudio = 3 Then $iWebAudio = 4 EndIf Case $msg = $hComboCam _WebcamDS_Reset() $aZoomPos[0] = 1 $aZoomPos[1] = 0 $aZoomPos[2] = 1 $aZoomPos[3] = 0 $iWebcam = _GUICtrlComboBox_GetCurSel($hComboCam) + 1 _WebcamDS_RenderWebcam($iWebcam, $iWebAudio, $hGUI, $iWebRescale, $iWebX, $iWebY, 16) Case $msg = $ZoomButton _WebcamDS_Reset() If $ZoomInput <> '' Then Local $aZoom = StringSplit($ZoomInput, ',') _WebcamDS_RenderWebcam($iWebcam, $iWebAudio, $hGUI, $iWebRescale, $iWebX, $iWebY, 16, $aZoom[1], $aZoom[2], $aZoom[3], $aZoom[4]) $ZoomInput = '' Else _WebcamDS_RenderWebcam($iWebcam, $iWebAudio, $hGUI, $iWebRescale, $iWebX, $iWebY, 16) $aZoomPos[0] = 1 $aZoomPos[1] = 0 $aZoomPos[2] = 1 $aZoomPos[3] = 0 EndIf Case $msg = $AudioPrevBox If GUICtrlRead($AudioPrevBox) = $GUI_CHECKED Then $iWebAudio = _GUICtrlComboBox_GetCurSel($hComboMic) + 1 If $iWebAudio = 3 Then $iWebAudio = 4 Else $iWebAudio = 0 EndIf Case $msg = $FullButton $oVideoWindow.put_FullScreenMode(-1) Case $msg = $GUI_EVENT_CLOSE GUIDelete() ExitLoop EndSelect If _IsPressed('70', $UserDLL) Then Local $full $oVideoWindow.get_FullScreenMode($full) If $full = -1 Then $oVideoWindow.put_FullScreenMode(0) _WebcamDS_Reset() EndIf EndIf If _IsPressed("01", $UserDLL) Then Local $aMouse_Pos = MouseGetPos() Local $iX1 = $aMouse_Pos[0] Local $iY1 = $aMouse_Pos[1] Local $aGUIPos = WinGetPos($hGUI) If WinGetState($hGUI) = 15 And $iX1 >= $aGUIPos[0] + 2 And $iX1 < $aGUIPos[0] + $aGUIPos[2] And $iY1 >= $aGUIPos[1] + 50 And $iY1 < $aGUIPos[1] + $aGUIPos[3] Then Local $sZoom = _WebcamDS_SelectRect($hGUI) If StringLen($sZoom) > 2 Then $ZoomInput = $sZoom ControlClick($hGUI, "", $ZoomButton) EndIf EndIf EndIf WEnd Func _CreateGui() Global $hGUI = GUICreate("DirectShow Capture", 1280, 720, -1, -1, -1) Global $AudioPrevBox = GUICtrlCreateCheckbox("AuPrev", 420, 0, 50, 25) Global $AudioCapBox = GUICtrlCreateCheckbox("AuCap", 795, 0, 50, 25) Global $FrameInput = GUICtrlCreateInput("30", 850, 0, 40, 25) Global $SaveButton = GUICtrlCreateButton("Save", 875, 0, 60, 25) Global $StopButton = GUICtrlCreateButton("Stop", 940, 0, 60, 25) Global $ZoomButton = GUICtrlCreateButton("Reset", 1120, 0, 70, 25) Global $FullButton = GUICtrlCreateButton("FullScreen", 1200, 0, 60, 25) GUISetState() If $hComboCam = '' Then For $i = 1 To $aWebcamList[0] If $hComboCam = '' Then $hComboCam = GUICtrlCreateCombo($aWebcamList[$i], 0, 0, 200, 25) Else If $aWebcamList[$i] <> '' Then GUICtrlSetData($hComboCam, $aWebcamList[$i]) EndIf Next EndIf If $hComboComp = '' Then For $i = 1 To $aCompressorList[0] + 1 If $hComboComp = '' Then $hComboComp = GUICtrlCreateCombo($aCompressorList[$i], 475, 0, 200, 25) Else GUICtrlSetData($hComboComp, $aCompressorList[$i]) EndIf ConsoleWrite($aCompressorList[$i] & @CRLF) Next EndIf If $hComboMic = '' Then For $i = 1 To $aMicList[0] If $hComboMic = '' Then $hComboMic = GUICtrlCreateCombo($aMicList[$i], 210, 0, 200, 25) Else GUICtrlSetData($hComboMic, $aMicList[$i]) EndIf Next EndIf EndFunc ;==>_CreateGui Func _onExit() ConsoleWrite('exit @error:' & @error & '@ext:' & @extended & @CRLF) _WebcamDS_ReleaseObjects(1) DllClose($UserDLL) EndFunc ;==>_onExit ; =========================================================================================================================== EXAMPLE ; ============================================================================================================ FUNCTIONS _WEBCAMDS Func _WebcamDS_Init() Local $hr, $aCall $oGraph = ObjCreateInterface($sCLSID_FilterGraph, $sIID_IGraphBuilder, $tagIGraphBuilder) If Not IsObj($oGraph) Then Return SetError(1, 0, 0) $oBuild = ObjCreateInterface($sCLSID_CaptureGraphBuilder2, $sIID_ICaptureGraphBuilder2, $tagICaptureGraphBuilder2) If Not IsObj($oBuild) Then Return SetError(2, 0, 0) $hr = $oBuild.SetFiltergraph($oGraph) If $hr < 0 Then Return SetError(0, 1, 0) Local $pMediaControl $oGraph.QueryInterface($sIID_IMediaControl, $pMediaControl) $oMediaControl = ObjCreateInterface($pMediaControl, $sIID_IMediaControl) If Not IsObj($oMediaControl) Then Return SetError(3, 0, 0) Local $pVideoWindow $oGraph.QueryInterface($sIID_IVideoWindow, $pVideoWindow) $oVideoWindow = ObjCreateInterface($pVideoWindow, $sIID_IVideoWindow, $tagIVideoWindow) If Not IsObj($oVideoWindow) Then Return SetError(4, 0, 0) Local $pBasicVideo $oGraph.QueryInterface($sIID_IBasicVideo, $pBasicVideo) $oBasicVideo = ObjCreateInterface($pBasicVideo, $sIID_IBasicVideo, $tagIBasicVideo) If Not IsObj($oBasicVideo) Then Return SetError(5, 0, 0) If $aWebcamList[1] = '' Then _WebcamDS_EnumerateDevices($sCLSID_VideoInputDeviceCategory) _WebcamDS_EnumerateDevices($sCLSID_VideoCompressorCategory) _WebcamDS_EnumerateDevices($sCLSID_AudioInputDeviceCategory) EndIf EndFunc ;==>_WebcamDS_Init Func _WebcamDS_EnumerateDevices($CLSID_category, $argument = 99) $oDevEnum = ObjCreateInterface($sCLSID_SystemDeviceEnum, $sIID_ICreateDevEnum, $tagICreateDevEnum) If Not IsObj($oDevEnum) Then Return SetError(6, 0, 0) Local $pEnum = 0 $oDevEnum.CreateClassEnumerator($CLSID_category, $pEnum, 0) $oEnum = ObjCreateInterface($pEnum, $sIID_IEnumMoniker, $tagIEnumMoniker) If Not IsObj($oEnum) Then Return SetError(7, 0, 0) Local $iPosition = '', $arg = '' If StringInStr($CLSID_category, "860bb310") Or StringInStr($CLSID_category, "33d9a762") Then $iPosition = $argument $arg = '' Else $iPosition = '' $arg = $argument EndIf Local $pMoniker, $oMoniker, $hr Local $i = 1, $pBindObj[99] While $oEnum.Next(1, $pMoniker, 0) = $S_OK Local $pPropBag, $oPropBag $oMoniker = ObjCreateInterface($pMoniker, $sIID_IMoniker, $tagIMoniker) If Not IsObj($oMoniker) Then Return SetError(8, 0, 0) $hr = $oMoniker.BindToObject(0, 0, $sIID_IBaseFilter, $pBindObj[$i]) If $hr < 0 Then ExitLoop $hr = $oMoniker.BindToStorage(0, 0, $sIID_IPropertyBag, $pPropBag) If $hr < 0 Then Return SetError(1, 2, 0) $oPropBag = ObjCreateInterface($pPropBag, $sIID_IPropertyBag, $tagIPropertyBag) If Not IsObj($oPropBag) Then Return SetError(9, 0, 0) Local $var = '' $hr = $oPropBag.Read("FriendlyName", $var, 0) If $hr < 0 Then Return SetError(1, 3, 0) If $iPosition = 99 Then If StringInStr($CLSID_category, "33d9a762") Then If $var <> '' Then $aMicList[$i] = $var EndIf Else If $var <> '' Then $aWebcamList[$i] = $var EndIf EndIf Local $oCaptureTemp = ObjCreateInterface($pBindObj[$i], $sIID_IBaseFilter, $tagIBaseFilter) $oCaptureTemp = 0 EndIf If $iPosition = '' And $arg = 99 Then If $var <> '' Then $aCompressorList[$i] = $var EndIf EndIf If ($iPosition <> '' And $iPosition = $i) Or ($arg <> '' And $var = $arg) Then If ($iPosition = '' And $arg = $var) Then If Not IsObj($oCompressor) Then $oCompressor = ObjCreateInterface($pBindObj[$i], $sIID_IBaseFilter, $tagIBaseFilter) If Not IsObj($oCompressor) Then Return SetError(10, 0, 0) EndIf $hr = $oGraph.AddFilter($oCompressor, "Compressor" & $iWebcam) If $hr < 0 Then Return SetError(1, 4, 0) ExitLoop EndIf If ($iPosition <> '' And $iPosition = $i) Then If StringInStr($CLSID_category, "33d9a762") Then If Not IsObj($oCaptureAudio) Then $oCaptureAudio = ObjCreateInterface($pBindObj[$i], $sIID_IBaseFilter, $tagIBaseFilter) If Not IsObj($oCaptureAudio) Then Return SetError(11, 0, 0) ConsoleWrite($iWebAudio & 'capAu:' & $i & @CRLF) EndIf $hr = $oGraph.AddFilter($oCaptureAudio, $var) If $hr < 0 Then Return SetError(1, 5, 0) Else If Not IsObj($oCapture[$iPosition]) Then $oCapture[$iPosition] = ObjCreateInterface($pBindObj[$i], $sIID_IBaseFilter, $tagIBaseFilter) If Not IsObj($oCapture[$iPosition]) Then Return SetError(12, 0, 0) EndIf $hr = $oGraph.AddFilter($oCapture[$iPosition], "CaptureFilter" & $iWebcam) If $hr < 0 Then Return SetError(1, 6, 0) WinSetTitle($hGUI, '', $var) EndIf ExitLoop EndIf EndIf $oPropBag = 0 $i += 1 WEnd If $iPosition = 99 And StringInStr($CLSID_category, "33d9a762") Then $aMicList[0] = $i - 1 If $iPosition = 99 And StringInStr($CLSID_category, "860bb310") Then $aWebcamList[0] = $i - 1 If $iPosition = '' And $arg = 99 Then $aCompressorList[$i] = 'Uncompressed' $aCompressorList[0] = $i - 1 EndIf $oMoniker = 0 $oEnum = 0 $oDevEnum = 0 EndFunc ;==>_WebcamDS_EnumerateDevices Func _WebcamDS_RenderWebcam($iNumberWebcam, $iAudioMic, $hGuiWin, $iScale = 1, $xVideo = 640, $yVideo = 480, $ibpp = 16, $iZoomX = 0, $iZoomY = 0, $iZoomW = 0, $iZoomH = 0) Local $hr $iWebcam = $iNumberWebcam $iWebAudio = $iAudioMic $iWebRescale = $iScale $iWebX = $xVideo $iWebY = $yVideo _WebcamDS_EnumerateDevices($sCLSID_VideoInputDeviceCategory, $iNumberWebcam) Local $_GUID = "DWORD Data1;" & "WORD Data2;" & "WORD Data3;" & "BYTE Data4[8];" Local $_SIZE = "LONG cx;" & "LONG cy;" Local $_VIDEO_STREAM_CONFIG_CAPS = $_GUID & "ULONG VideoStandard;" & $_SIZE & $_SIZE & $_SIZE & "int CropGranularityX;" & "int CropGranularityY;" & "int CropAlignX;" & "int CropAlignY;" & $_SIZE & $_SIZE & "int OutputGranularityX;" & "int OutputGranularityY;" & "int StretchTapsX;" & "int StretchTapsY;" & "int ShrinkTapsX;" & "int ShrinkTapsY;" & "int64 MinFrameInterval;" & "int64 MaxFrameInterval;" & "LONG MinBitsPerSecond;" & "LONG MaxBitsPerSecond;" Local $tVideoStream = DllStructCreate($_VIDEO_STREAM_CONFIG_CAPS) Local $_AM_MEDIA = $_GUID & $_GUID & 'BOOL bFixedSizeSamples;' & 'BOOL bTemporalCompression;' & 'ULONG lSampleSize;' & $_GUID & 'ptr pUnk;' & 'ULONG cbFormat;' & 'ptr pbFormat;' Local $t_AM_MEDIA = DllStructCreate($_AM_MEDIA) Local $_RECT = 'LONG left;' & 'LONG top;' & 'LONG right;' & 'LONG bottom;' Local $_tagBITMAPINFOHEADER = 'DWORD biSize;' & 'LONG biWidth;' & 'LONG biHeight;' & 'WORD biPlanes;' & 'WORD biBitCount;' & 'DWORD biCompression;' & 'DWORD biSizeImage;' & 'LONG biXPelsPerMeter;' & 'LONG biYPelsPerMeter;' & 'DWORD biClrUsed;' & 'DWORD biClrImportant;' Local $_tagVIDEOINFOHEADER = $_RECT & $_RECT & 'DWORD dwBitRate;' & 'DWORD dwBitErrorRate;' & 'int64 AvgTimePerFrame;' & $_tagBITMAPINFOHEADER Local $_PinInfo = 'ptr pFilter;' & 'int64 dir;' & 'wchar achName[128];' Local $pConfig $hr = $oBuild.FindInterface($PIN_CATEGORY_CAPTURE, $MEDIATYPE_Video, $oCapture[$iNumberWebcam], $sIID_IAMStreamConfig, $pConfig) $oStreamConfig = ObjCreateInterface($pConfig, $sIID_IAMStreamConfig, $tagIAMStreamConfig) If Not IsObj($oStreamConfig) Then Return SetError(13, 0, 0) Local $iCount = 0, $iSize = 0 $hr = $oStreamConfig.GetNumberOfCapabilities($iCount, $iSize) If $hr < 0 Then Return SetError(1, 7, 0) If DllStructGetSize($tVideoStream) == $iSize Then For $iFormat = 0 To $iCount - 1 Step 1 Local $scc = DllStructGetPtr($tVideoStream) Local $pmtConfig = DllStructGetPtr($t_AM_MEDIA) $hr = $oStreamConfig.GetStreamCaps($iFormat, $pmtConfig, $scc) Local $t_AM_MEDIA_TYPE = DllStructCreate($_AM_MEDIA, $pmtConfig) Local $pbFormat = DllStructGetData($t_AM_MEDIA_TYPE, "pbFormat") Local $t_VIDEOINFOHEADER = DllStructCreate($_tagVIDEOINFOHEADER, $pbFormat) Local $videoWidth = DllStructGetData($t_VIDEOINFOHEADER, 'biWidth') Local $videoHeight = DllStructGetData($t_VIDEOINFOHEADER, 'biHeight') Local $bitCount = DllStructGetData($t_VIDEOINFOHEADER, 'biBitCount') Local $dwBitRate = DllStructGetData($t_VIDEOINFOHEADER, 'dwBitRate') Local $biCompression = DllStructGetData($t_VIDEOINFOHEADER, 'biCompression') Local $biPlanes = DllStructGetData($t_VIDEOINFOHEADER, 'biPlanes') Local $biSize = DllStructGetData($t_VIDEOINFOHEADER, 'biSizeImage') Local $AvgframeRate = Round(10000000 / DllStructGetData($t_VIDEOINFOHEADER, 'AvgTimePerFrame')) Local $sText = '' For $i = 7 To 0 Step -2 If $biCompression <> 0 Then $sText = $sText & Chr(Dec(StringMid(Hex($biCompression, 8), $i, 2))) Next Local $FrameRate = GUICtrlRead($FrameInput) DllStructSetData($t_VIDEOINFOHEADER, 'AvgTimePerFrame', 10000000 / $FrameRate) If $videoWidth = $xVideo And $videoHeight = $yVideo And $bitCount = $ibpp Then $hr = $oStreamConfig.SetFormat(DllStructGetPtr($t_AM_MEDIA_TYPE)) If $hr < 0 Then Return SetError(1, 8, 0) ExitLoop EndIf If $iFormat = $iCount - 1 Then DllStructSetData($t_VIDEOINFOHEADER, 'biWidth', $xVideo) DllStructSetData($t_VIDEOINFOHEADER, 'biHeight', $yVideo) DllStructSetData($t_VIDEOINFOHEADER, 'biBitCount', $ibpp) $hr = $oStreamConfig.SetFormat(DllStructGetPtr($t_AM_MEDIA_TYPE)) If $hr < 0 Then Return SetError(1, 9, 0) EndIf Next WinSetTitle($hGuiWin, '', WinGetTitle($hGuiWin) & ' - ' & $xVideo & 'x' & $yVideo & 'x' & $ibpp) $oStreamConfig = 0 EndIf If $iAudioMic <> 0 Then _WebcamDS_EnumerateDevices($sCLSID_AudioInputDeviceCategory, $iAudioMic) $pConfig = '' $hr = $oBuild.FindInterface($PIN_CATEGORY_CAPTURE, $MEDIATYPE_Audio, $oCaptureAudio, $sIID_IAMStreamConfig, $pConfig) Global $oAStreamConfig = ObjCreateInterface($pConfig, $sIID_IAMStreamConfig, $tagIAMStreamConfig) EndIf If $Vmr9 = 0 Then $hr = $oBuild.RenderStream($PIN_CATEGORY_PREVIEW, $MEDIATYPE_Video, $oCapture[$iNumberWebcam], 0, 0) If $hr < 0 Then Return SetError(1, 10, 0) If IsObj($oCaptureAudio) Then $hr = $oBuild.RenderStream($PIN_CATEGORY_PREVIEW, $MEDIATYPE_Audio, $oCaptureAudio, 0, 0) Else $oVmr9 = ObjCreateInterface($sCLSID_VideoMixingRenderer9, $sIID_IBaseFilter, $tagIBaseFilter) If Not IsObj($oVmr9) Then Return SetError(14, 0, 0) $hr = $oGraph.AddFilter($oVmr9, "VMR9") If $hr < 0 Then Return SetError(1, 11, 0) Local $pConfig9, $oConfig9 $hr = $oVmr9.QueryInterface($sIID_IVMRFilterConfig9, $pConfig9) $oConfig9 = ObjCreateInterface($pConfig9, $sIID_IVMRFilterConfig9, $tagIVMRFilterConfig9) If Not IsObj($oConfig9) Then Return SetError(15, 0, 0) ConsoleWrite('Filterconf hr:' & $hr & ' ' & IsObj($oConfig9) & @CRLF) Local $str = '' $hr = $oConfig9.SetNumberOfStreams(4) If $hr < 0 Then Return SetError(1, 12, 0) ConsoleWrite('NumberStream hr:' & $hr & ' Get:' & $str & @CRLF) Local $pMixControl9, $oMixControl9 $hr = $oVmr9.QueryInterface($sIID_IVMRMixerControl9, $pMixControl9) ConsoleWrite('Mixercontrol9 hr:' & $hr & @CRLF) $oMixControl9 = ObjCreateInterface($pMixControl9, $sIID_IVMRMixerControl9, $tagIVMRMixerControl9) If Not IsObj($oMixControl9) Then Return SetError(16, 0, 0) Local $t_VMR9rect = DllStructCreate($_RECT) Local $l = 0, $t = 0, $r = $l + $xVideo, $b = $t + $yVideo DllStructSetData($t_VMR9rect, 'left', $l) DllStructSetData($t_VMR9rect, 'top', $t) DllStructSetData($t_VMR9rect, 'right', $r) DllStructSetData($t_VMR9rect, 'bottom', $b) Local $streamID = 0 $hr = $oMixControl9.SetOutputRect($streamID, DllStructGetPtr($t_VMR9rect)) ConsoleWrite('Output rect0 hr:' & $hr & @CRLF) If $hr < 0 Then Return SetError(1, 13, 0) $oConfig9 = 0 $oMixControl9 = 0 $hr = $oBuild.RenderStream($PIN_CATEGORY_PREVIEW, $MEDIATYPE_Video, $oCapture[$iNumberWebcam], 0, $oVmr9) If $hr < 0 Then Return SetError(1, 14, 0) If IsObj($oCaptureAudio) Then $hr = $oBuild.RenderStream($PIN_CATEGORY_PREVIEW, $MEDIATYPE_Audio, $oCaptureAudio, 0, 0) $oVmr9 = 0 EndIf Local $iX = $iWebXinside, $iY = $iWebYinside Local $aClientSize = WinGetClientSize($hGuiWin) If $iScale = 1 Then $xVideo = $aClientSize[0] $yVideo = $aClientSize[1] EndIf If $iZoomW <> 0 Then $hr = $oBasicVideo.SetSourcePosition($iZoomX, $iZoomY, $iZoomW, $iZoomH) If $hr < 0 Then Return SetError(1, 15, 0) EndIf $hr = $oVideoWindow.SetWindowPosition($iX, $iY, $xVideo, $yVideo) If $hr < 0 Then Return SetError(1, 16, 0) $hr = $oVideoWindow.put_Owner($hGuiWin) If $hr < 0 Then Return SetError(1, 17, 0) $oVideoWindow.put_WindowStyle(BitOR($WS_CHILD, $WS_CLIPCHILDREN)) If $hr < 0 Then Return SetError(1, 18, 0) $hr = $oMediaControl.Run() If $hr < 0 Then Return SetError(1, 19, 0) EndFunc ;==>_WebcamDS_RenderWebcam Func _WebcamDS_SaveFile($sFileName, $sCompress = 'Uncompressed', $iAudioMic = 0) Local $hr $hr = $oMediaControl.Stop() _WebcamDS_EnumerateDevices($sCLSID_VideoCompressorCategory, $sCompress) If $sCompress <> 'Uncompressed' Then Local $i = 0, $pEnum, $oCompress, $oPin $hr = $oCompressor.EnumPins($pEnum) $oEnum = ObjCreateInterface($pEnum, $sIID_IEnumPins, $tagIEnumPins) Local $pPin, $pCompress While $oEnum.Next(1, $pPin, 0) = $S_OK $oPin = ObjCreateInterface($pPin, $sIID_IPin, $tagIPin) $hr = $oPin.QueryInterface($sIID_IAMVideoCompression, $pCompress) $oCompress = ObjCreateInterface($pCompress, $sIID_IAMVideoCompression, $tagIAMVideoCompression) $oPin = 0 $i += 1 If $hr >= 0 Then ExitLoop EndIf $oCompress = 0 WEnd $oEnum = 0 $oPin = 0 If $hr >= 0 Then Local $Cap, $KeyFrameDef, $PFrameDef, $QualityDef, $KeyFrame, $PFrame, $m_Quality $hr = $oCompress.GetInfo(0, 0, 0, 0, $KeyFrameDef, $PFrameDef, $QualityDef, $Cap) If $hr >= 0 Then If BitAND($Cap, $CompressionCaps_CanKeyFrame) Then $hr = $oCompress.get_KeyFrameRate($KeyFrame) If $hr < 0 Or $KeyFrame < 0 Then $KeyFrame = $KeyFrameDef EndIf EndIf EndIf Else $oCompressor = 0 EndIf Local $pMux, $oMux $hr = $oBuild.SetOutputFileName($MEDIASUBTYPE_Avi, $sFileName, $pMux, 0) $oMux = ObjCreateInterface($pMux, $sIID_IBaseFilter, $tagIBaseFilter) If Not IsObj($oMux) Then Return SetError(19, 0, 0) $oCompressor = "Microsoft Video 1" $hr = $oBuild.RenderStream($PIN_CATEGORY_CAPTURE, $MEDIATYPE_Video, $oCapture[$iWebcam], $oCompressor, $oMux) If $iAudioMic <> 0 Then _WebcamDS_EnumerateDevices($sCLSID_AudioInputDeviceCategory, $iAudioMic) $hr = $oBuild.RenderStream($PIN_CATEGORY_CAPTURE, $MEDIATYPE_Audio, $oCaptureAudio, 0, $oMux) EndIf $oMux = 0 $oMediaControl.Run() EndFunc ;==>_WebcamDS_SaveFile Func _WebcamDS_ReleaseObjects($iArg = 0) $oMediaControl.Stop() $oMediaControl = 0 $oVmr9 = 0 $oCapture[$iWebcam] = 0 If $iArg Then $oCapture = 0 $oCaptureAudio = 0 $oBasicAudio = 0 $oBasicVideo = 0 $oVideoWindow = 0 $oGraph = 0 $oBuild = 0 $oCompressor = 0 EndFunc ;==>_WebcamDS_ReleaseObjects Func _WebcamDS_SelectRect($hGuiWin) Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp $aMouse_Pos = MouseGetPos() Local $iX1 = $aMouse_Pos[0] Local $iY1 = $aMouse_Pos[1] While _IsPressed("01", $UserDLL) $aMouse_Pos = MouseGetPos() Sleep(10) WEnd Local $iX2 = $aMouse_Pos[0] Local $iY2 = $aMouse_Pos[1] If $iX2 < $iX1 Then $iTemp = $iX1 $iX1 = $iX2 $iX2 = $iTemp EndIf If $iY2 < $iY1 Then $iTemp = $iY1 $iY1 = $iY2 $iY2 = $iTemp EndIf Local $aGUIPos = WinGetPos($hGuiWin) Local $aGUISize = WinGetClientSize($hGuiWin) Local $sZoom If $iX1 <> $iX2 Then If $iWebRescale = 1 And $aZoomPos[0] = 1 Then $aZoomPos[0] = $aGUISize[0] / $iWebX $aZoomPos[2] = $aGUISize[1] / $iWebY EndIf $sZoom = ($iX1 - $aGUIPos[0]) / $aZoomPos[0] + $aZoomPos[1] & "," & ($iY1 - ($aGUIPos[1] + 50)) / $aZoomPos[2] + $aZoomPos[3] & "," & ($iX2 - $iX1) / $aZoomPos[0] & "," & ($iY2 - $iY1) / $aZoomPos[2] Local $aZoomPosTemp[4], $iSizeX, $iSizeY If $iWebRescale = 1 Then $iSizeX = $aGUISize[0] $iSizeY = $aGUISize[1] Else $iSizeX = $iWebX $iSizeY = $iWebY EndIf $aZoomPosTemp[0] = $iSizeX / (($iX2 - $iX1) / $aZoomPos[0]) $aZoomPosTemp[2] = $iSizeY / (($iY2 - $iY1) / $aZoomPos[2]) $aZoomPosTemp[1] = ($iX1 - $aGUIPos[0]) / $aZoomPos[0] + $aZoomPos[1] $aZoomPosTemp[3] = ($iY1 - ($aGUIPos[1] + 50)) / $aZoomPos[2] + $aZoomPos[3] $aZoomPos[0] = $aZoomPosTemp[0] $aZoomPos[1] = $aZoomPosTemp[1] $aZoomPos[2] = $aZoomPosTemp[2] $aZoomPos[3] = $aZoomPosTemp[3] Return $sZoom EndIf EndFunc ;==>_WebcamDS_SelectRect Func _WebcamDS_Reset() _WebcamDS_ReleaseObjects() _WebcamDS_Init() EndFunc ;==>_WebcamDS_Reset ; ============================================================================================================ FUNCTIONS _WEBCAMDS
  15. @mLipok the UDF you modified opens the interface but does not show the camera image and returns several errors "NULL Pointer assignment" and "Variable must be of type 'Object'." Then I tested with the UDF without changes, it opens the camera image without errors. WebcamDS_ExampleUDF.au3 (490) : ==> COM Error intercepted ! err.number is: 0x00000003 err.windescription: NULL Pointer assignment err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 490 err.retcode is: 0x00000000 WebcamDS_ExampleUDF.au3 (504) : ==> COM Error intercepted ! err.number is: 0x000000A9 err.windescription: Variable must be of type 'Object'. err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 504 err.retcode is: 0x00000000 WebcamDS_ExampleUDF.au3 (490) : ==> COM Error intercepted ! err.number is: 0x00000003 err.windescription: NULL Pointer assignment err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 490 err.retcode is: 0x00000000 WebcamDS_ExampleUDF.au3 (504) : ==> COM Error intercepted ! err.number is: 0x000000A9 err.windescription: Variable must be of type 'Object'. err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 504 err.retcode is: 0x00000000 WebcamDS_ExampleUDF.au3 (274) : ==> COM Error intercepted ! err.number is: 0x00000003 err.windescription: NULL Pointer assignment err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 274 err.retcode is: 0x00000000 +>16:41:49 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 13.331
×
×
  • Create New...