Search the Community
Showing results for tags 'AVI'.
-
Hello Guys i am new to Autoit. I am currently writing a GUI which is displaying a avi. My question now is how can i use a avi i added with Autoit3wrapper Thanks is advance Zombie
-
An other tool for AutoIt Coders : Gif2Avi permit to convert an animated Gif to an Avi file for use with the (rarely used) GUICtrlCreateAvi function. Use an Avi file as loader or animation in a script (see StringFinder for example) is easier than use an animated gif. With this little tool you can also : _ Set the AVI file dimensions ( height will follow width changes for preserve ratio W/H ) _ Change FPS (frames per second) _ Try an other background color ( used in _GDIPlus_BitmapCreateHBITMAPFromBitmap function) _ Crop width and height (From the original dimension) Thanks to monoceres, Prog@ndy and UEZ for AVI functions. Source and compiled Version are available in the Download Section. May be the "GUICtrlCreateAvi" function will be a bit more used ! Some Links for find or create loaders/spinners preloaders.net loading.io dribbble.com chimply.com tools.bit-hive.com
-
XvidCapture, demo capturing made easy, into avi video file with stereo sound. Script use XvidCapture.dll made for freebasic by D.J.Peters Major defects : The frame rate need to be limited due to the time for write datas (80-130 ms by frame with a 1920x1080 screen size and a 640x480 video size). The dll support only uncompressed wav audio format (do not work with mp3) The quality setting doesn't seem to change anything. Tested with AutoIt 3.3.8.1 on WinXP SP3 and AutoIt 3.3.12.0 on Win7/Win8.1 On my netbook using XP, i need to set fps to 5 with 320x240 ! On my Destop PC using W7 or W8.1 , i need to set fps to 7 with 854x480 ! So don't expect a video in high-definition with dolby surround from a little dll of 153 ko ! If FPS can be respected by the script, the audio and video can be synchronized, so adjust settings depending on the config of your pc. As usual externals files are embedded in script. Thanks to Smashly for his wave functions and also UEZ, Authenticity, Eukalyptus and jpm for the new GDIPLUS functions. source for 3.3.12.0 : XvidCapture v1.0.1.6.au3.html source for previous versions : XvidCapture v1.0.1.6 PreviousAutoItVersions.au3.html executable : XvidCapture.exe.html
-
I love GifCam. Easy and handy to use for create animated gif from capture. For the fun, i have tried to do it in AutoIt. GifSicle is only used for compress animated Gif when saving or decompress when loading. Due to a lack of time, I have not re-created all the features of latest GifCam Version. Warning : Use latest AutoIt release (v3.3.12.0) and script do not work under XP. source and executable are available in the Download Section Hope you like it ! If not, try the Original !
-
I'm trying to activate the compression feature in AVIFIL32.DLL using monoceres' My problem is that the return value of the call $aRet = DllCall($Avi32_Dll, "int", "AVIMakeCompressedStream", "ptr*", 0, "ptr", $pstream, "ptr", DllStructGetPtr($aco), "ptr*", 0)is always 0x80040154 which is an error. You can check out at MSDN how the AVI functions have to be called. Further I tried understand the VB5 code how the code is activating the compression. Here the modified AVIWriter code which will take for 5 seconds at 15 fps screenshots from active window and put it to the avi container: #AutoIt3Wrapper_UseX64=n #include <WinAPI.au3> #region AVIWriter UDF ;Global Const $mmioFOURCC_M_S_V_C = _Create_mmioFOURCC("MSVC") ;1129730893 Global Const $BITMAPFILEHEADER = "align 2;char magic[2];int size;short res1;short res2;ptr offset;" Global Const $BITMAPINFOHEADER = "dword biSize;long biWidth;long biHeight;short biPlanes;short biBitCount;" & _ "dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;" Global Const $OF_CREATE = 0x00001000 Global Const $AVIIF_KEYFRAME = 0x00000010 Global Const $ICMF_CHOOSE_KEYFRAME = 1, $ICMF_CHOOSE_DATARATE = 2 Global Const $AVIERR_UNSUPPORTED = 0x80044065 Global Const $AVIERR_MEMORY = 0x80044067 Global Const $AVIERR_NOCOMPRESSOR = 0x80044071 Global Const $AVIERR_CANTCOMPRESS = 0x80044075 Global Const $AVIERR_ERROR = 0x800440C7 Global Const $AVIERR_OK = 0 Global $Avi32_Dll ;http://msdn.microsoft.com/en-us/library/ms899423.aspx Global Const $AVISTREAMINFO = "dword fccType;dword fccHandler;dword dwFlags;dword dwCaps;short wPriority;short wLanguage;dword dwScale;" & _ "dword dwRate;dword dwStart;dword dwLength;dword dwInitialFrames;dword dwSuggestedBufferSize;dword dwQuality;" & _ "dword dwSampleSize;int rleft;int rtop;int rright;int rbottom;dword dwEditCount;dword dwFormatChangeCount;wchar[64];" ;http://msdn.microsoft.com/en-us/library/dd756791(v=VS.85).aspx Global Const $AVICOMPRESSOPTIONS = "DWORD fccType;DWORD fccHandler;DWORD dwKeyFrameEvery;DWORD dwQuality;DWORD dwBytesPerSecond;" & _ "DWORD dwFlags;PTR lpFormat;DWORD cbFormat;PTR lpParms;DWORD cbParms;DWORD dwInterleaveEvery;" Func _Create_mmioFOURCC($FOURCC) ;http://www.fourcc.org/codecs.php If StringLen($FOURCC) <> 4 Then Return SetError(1, 0, 0) Local $aFOURCC = StringSplit($FOURCC, "", 2) Return BitOR(Asc($aFOURCC[0]), BitShift(Asc($aFOURCC[1]), -8), BitShift(Asc($aFOURCC[2]), -16), BitShift(Asc($aFOURCC[3]), -24)) EndFunc ;==>_Create_mmioFOURCC Func _DecodeFOURCC($iFOURCC) If Not IsInt($iFOURCC) Then Return SetError(1, 0, 0) Return Chr(BitAND($iFOURCC, 0xFF)) & Chr(BitShift(BitAND(0x0000FF00, $iFOURCC), 8)) & Chr(BitShift(BitAND(0x00FF0000, $iFOURCC), 16)) & Chr(BitShift($iFOURCC, 24)) EndFunc ;==>_DecodeFOURCC ; monoceres, Prog@ndy Func _CreateAvi($sFilename, $FrameRate, $Width, $Height, $BitCount = 24, $mmioFOURCC = "MSVC") Local $RetArr[5] ; avi file handle, stream handle, bitmap count, BitmapInfoheader, Stride Local $aRet, $pfile, $asi, $aco, $pstream, $psCompressed $aRet = DllCall($Avi32_Dll, "int", "AVIFileOpenW", "ptr*", 0, "wstr", $sFilename, "uint", $OF_CREATE, "ptr", 0) $pfile = $aRet[1] Local $stride = BitAND(($Width * ($BitCount / 8) + 3), BitNOT(3)) Local $bi = DllStructCreate($BITMAPINFOHEADER) DllStructSetData($bi, "biSize", DllStructGetSize($bi)) DllStructSetData($bi, "biWidth", $Width) DllStructSetData($bi, "biHeight", $Height) DllStructSetData($bi, "biPlanes", 1) DllStructSetData($bi, "biBitCount", $BitCount) DllStructSetData($bi, "biSizeImage", $stride * $Height) $asi = DllStructCreate($AVISTREAMINFO) DllStructSetData($asi, "fccType", _Create_mmioFOURCC("vids")) DllStructSetData($asi, "fccHandler", 0) ;_Create_mmioFOURCC($mmioFOURCC)) DllStructSetData($asi, "dwScale", 1) DllStructSetData($asi, "dwRate", $FrameRate) ;~ DllStructSetData($asi, "dwQuality", $Quality) ;Quality is represented as a number between 0 and 10,000. For compressed data, this typically represents the value of the quality parameter passed to the compression software. If set to –1, drivers use the default quality value. DllStructSetData($asi, "rright", $Width) DllStructSetData($asi, "rbottom", $Height) ;~ DllStructSetData($asi, "dwSuggestedBufferSize", $stride * $Height) $aRet = DllCall($Avi32_Dll, "int", "AVIFileCreateStream", "ptr", $pfile, "ptr*", 0, "ptr", DllStructGetPtr($asi)) $pstream = $aRet[2] $aco = DllStructCreate($AVICOMPRESSOPTIONS) Local $hWnd= GUICreate("") $aRet = DllCall($Avi32_Dll, "int_ptr", "AVISaveOptions", "hwnd", $hWnd, "uint", BitOR($ICMF_CHOOSE_DATARATE, $ICMF_CHOOSE_KEYFRAME), "int", 1, "ptr*", $pstream, "ptr*", DllStructGetPtr($aco)) GUIDelete($hWnd) If $aRet[0] <> 1 Then $RetArr[0] = $pfile $RetArr[1] = $pstream Return SetError(1, 0, $RetArr) EndIf ConsoleWrite(_DecodeFOURCC(DllStructGetData($aco, "fccHandler")) & @CRLF) $aRet = DllCall($Avi32_Dll, "int", "AVIMakeCompressedStream", "ptr*", 0, "ptr", $pstream, "ptr", DllStructGetPtr($aco), "ptr*", 0) ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aRet = ' & $aRet & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aRet = ' & Hex($aRet[0]) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console If $aRet[0] <> $AVIERR_OK Then $RetArr[0] = $pfile $RetArr[1] = $pstream Return SetError(2, 0, $RetArr) EndIf $psCompressed = $aRet[1] ; The format for the stream is the same as BITMAPINFOHEADER $aRet = DllCall($Avi32_Dll, "int", "AVIStreamSetFormat", "ptr", $psCompressed, "long", 0, "ptr", DllStructGetPtr($bi), "long", DllStructGetSize($bi)) $RetArr[0] = $pfile $RetArr[1] = $psCompressed $RetArr[2] = 0 $RetArr[3] = $bi $RetArr[4] = $stride Return $RetArr EndFunc ;==>_CreateAvi ; Adds a bitmap file to an already opened avi file. ; monoceres, Prog@ndy Func _AddHBitmapToAvi(ByRef $Avi_Handle, $hBitmap) Local $DC = _WinAPI_GetDC(0) Local $hDC = _WinAPI_CreateCompatibleDC($DC) _WinAPI_ReleaseDC(0, $DC) Local $OldBMP = _WinAPI_SelectObject($hDC, $hBitmap) Local $bits = DllStructCreate("byte[" & DllStructGetData($Avi_Handle[3], "biSizeImage") & "]") _WinAPI_GetDIBits($hDC, $hBitmap, 0, Abs(DllStructGetData($Avi_Handle[3], "biHeight")), DllStructGetPtr($bits), DllStructGetPtr($Avi_Handle[3]), 0) _WinAPI_SelectObject($hDC, $OldBMP) _WinAPI_DeleteDC($hDC) DllCall($Avi32_Dll, "int", "AVIStreamWrite", "ptr", $Avi_Handle[1], "long", $Avi_Handle[2], "long", 1, "ptr", DllStructGetPtr($bits), _ "long", DllStructGetSize($bits), "long", $AVIIF_KEYFRAME, "ptr*", 0, "ptr*", 0) $Avi_Handle[2] += 1 EndFunc ;==>_AddHBitmapToAvi ; Adds a bitmap file to an already opened avi file. Func _AddBitmapToAvi(ByRef $Avi_Handle, $sBitmap) Local $bm = LoadBitmap($sBitmap, True) DllCall($Avi32_Dll, "int", "AVIStreamWrite", "ptr", $Avi_Handle[1], "long", $Avi_Handle[2], "long", 1, "ptr", DllStructGetPtr($bm[2]), _ "long", DllStructGetSize($bm[2]), "long", $AVIIF_KEYFRAME, "ptr*", 0, "ptr*", 0) $Avi_Handle[2] += 1 EndFunc ;==>_AddBitmapToAvi ; Returns array with 3 elements ; [0]=BITMAPFILEHEADER ; [1]=BITMAPINFOHEADER ; [2]=Bitmap data buffer (if specified) Func LoadBitmap($sFilename, $LoadData = False) Local $RetArr[3] Local $byref Local $bih, $bfh, $buffer, $fhandle $bfh = DllStructCreate($BITMAPFILEHEADER) $bih = DllStructCreate($BITMAPINFOHEADER) $fhandle = _WinAPI_CreateFile($sFilename, 2, 2, 0, 0) _WinAPI_ReadFile($fhandle, DllStructGetPtr($bfh), DllStructGetSize($bfh), $byref) _WinAPI_ReadFile($fhandle, DllStructGetPtr($bih), DllStructGetSize($bih), $byref) $RetArr[0] = $bfh $RetArr[1] = $bih If Not $LoadData Then _WinAPI_CloseHandle($fhandle) Return $RetArr EndIf $buffer = DllStructCreate("byte[" & DllStructGetData($bfh, "size") - 54 & "]") $RetArr[2] = $buffer _WinAPI_ReadFile($fhandle, DllStructGetPtr($buffer), DllStructGetSize($buffer), $byref) _WinAPI_CloseHandle($fhandle) Return $RetArr EndFunc ;==>LoadBitmap ; Init the avi library Func _StartAviLibrary() $Avi32_Dll = DllOpen("Avifil32.dll") DllCall($Avi32_Dll, "none", "AVIFileInit") ;~ MsgBox(0,"",@error) EndFunc ;==>_StartAviLibrary ; Release the library Func _StopAviLibrary() DllCall($Avi32_Dll, "none", "AVIFileExit") DllClose($Avi32_Dll) EndFunc ;==>_StopAviLibrary Func _CloseAvi($Avi_Handle) DllCall($Avi32_Dll, "int", "AVIStreamRelease", "ptr", $Avi_Handle[1]) DllCall($Avi32_Dll, "int", "AVIFileRelease", "ptr", $Avi_Handle[0]) EndFunc ;==>_CloseAvi #endregion #region example #include <Array.au3> #include <Memory.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() HotKeySet("{ESC}", "close") Break(0) FileDelete(@ScriptDir & "\test.avi") $tPoint = DllStructCreate($tagPOINT) $aMPos = MouseGetPos() DllStructSetData($tPoint, 1, $aMPos[0]) DllStructSetData($tPoint, 2, $aMPos[1]) $hWin = _WinAPI_WindowFromPoint($tPoint) $hWinAncestor = _WinAPI_GetAncestor($hWin, 2) $hWnd = HWnd($hWinAncestor) $aPos = WinGetPos($hWnd) $rec_duration = 1000 * 1 ConsoleWrite("Starting...." & @CRLF) _StartAviLibrary() $aAVI = _CreateAvi(@ScriptDir & "\test.avi", 15, $aPos[2], $aPos[3]) If @error Then close() $t = TimerInit() Do $hBmp = _ScreenCapture_CaptureWnd("", $hWnd) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) _AddHBitmapToAvi($aAVI, $hBmp) _WinAPI_DeleteObject($hBmp) If TimerDiff($t) > $rec_duration Then close() Until False Func close() _GDIPlus_Shutdown() _CloseAvi($aAVI) _StopAviLibrary() ConsoleWrite("AVI filesize: " & Round(FileGetSize(@ScriptDir & "\test.avi") / 1024^2, 2) & " MB" & @CRLF) Exit EndFunc ;==>close #endregion When you start it you can select the codec for the compression but the script will stop because the return code of the function AVIMakeCompressedStream is not 0. Any ideas how to pass properly the parameter of that function call? Thanks, UEZ
- 13 replies
-
- avi
- compression
-
(and 1 more)
Tagged with:
-
Hi I am trying to embed an icon control and an AVI control in the status bar but the problem is they won't retain their transparency. An example: #include <GuiStatusBar.au3> #include <GUIConstantsEx.au3> Global $WindowMain = GUICreate("Example", 351, 176, -1, -1) GUISetBkColor( 0xDDDDDD, $WindowMain ) Global $Statusbar = _GUICtrlStatusBar_Create($WindowMain) Global $Statusbar_PartsWidth[2] = [324, -1] _GUICtrlStatusBar_SetParts($Statusbar, $Statusbar_PartsWidth) _GUICtrlStatusBar_SetText($Statusbar, "", 0) _GUICtrlStatusBar_SetText($Statusbar, "", 1) _GUICtrlStatusBar_SetMinHeight($Statusbar, 20) GUISetState(@SW_SHOW) $Icon = GUICtrlCreateIcon('ico.ico',-1,300,130,16,16) ;Icon on GUI ;Without this the icon will not be tranparent. No idea why. GUICtrlSetState($icon, $GUI_SHOW) $Icon2 = GUICtrlCreateIcon('ico.ico',-1,10,10,16,16) _GUICtrlStatusBar_EmbedControl($Statusbar, 1, GUICtrlGetHandle($Icon2), 1+2) ; This has no effect. Icon has a white square around it GUICtrlSetState($icon2, $GUI_SHOW) $AVI = GUICtrlCreateAvi( 'avi.avi',0,250,130,16,16) GUICtrlSetState( $AVI, 1 ) $AVI2 = GUICtrlCreateAvi( 'avi.avi',0,250,130,16,16) GUICtrlSetState( $AVI2, 1 ) _GUICtrlStatusBar_EmbedControl($Statusbar, 0, GUICtrlGetHandle($AVI2), 1+2) Global $GuiMsg Do $GuiMsg = GUIGetMsg() Until $GuiMsg = $GUI_EVENT_CLOSE I've tried a couple of things like using _GUICtrlStatusBar_SetIcon() or GDIplus for icons and that works and the icons are transparent. As for the AVI, I tried faking a status bar by drawing some lines at the buttom of the window and that worked ok too, But I'd love to be able to use it with a real status bar. example.zip