Jump to content
UEZ

FrameGrabber.Dll usage and developement

Recommended Posts

UEZ

It's written in VScript. That's my version of AutoIt. It has pretty much the same syntax as AutoIt, but has true compiler. It's what I wanted to do with AutoIt while being active in development. Anyway, not to repeat myself, some limited fuckers had different ideas.
Oh, and Jon doesn't want me to talk about my work on AutoIt on the forums, so that's about all the info I'm willing to share.

Not all codecs support frame count format, particularly those that handle streaming video formats, because streaming is done in time intervals, and not in frames. I can explain the algo if you want, the code can obviously be written in AutoIt.
We are going off-topic here, so create new thread somewhere if you want to go further. No PMs please.

Link and example: FrameGrabber.dll 

What about my question regarding returning a bitmap handle or bitmap data rather than saving the grabbed frame to disk?

Actually I would talk about VScript because I'm curious but Jon doesn't want it but can you show me the code please? You said it is similar to AU3 code. I want to understand how you did it.

 

Thanks.

 

 

 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
wakillon

The silence of trancexx seems to indicate that It's not possible !

For get frame by frame you just have to set the times depending of the FPS

 

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
UEZ

Nope, wrong forum section. Maybe this topic will be moved to "Developer Chat" section.

Afterwards will be see...

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
trancexx

It uses IVMRWindowlessControl interface, particularly GetCurrentImage method. Unlike other similar methods from other interfaces, this one succeeds regardless of possible hardware acceleration.

The problem with DirectShow is plethora of deprecated interfaces, that should no longer be used. That's why it's very important not to use such interfaces for forward compatibility.
GetCurrentImage gets 32-bit DIB bitmap. To answer your question about whether bitmap data could be returned - yes. Last step of this version of frame grabber is simple prepending BMP header to that DIB and writing all that to disk.
Complete description of the code is:

  1. Create IGraphBuilder interface object - by calling ObjCreateInterface passing CLSID_FilterGraph and IID_IGraphBuilder
  2. Create IBaseFilter (Video Mixing Renderer here) object - by calling ObjCreateInterface passing CLSID_VideoMixingRenderer and IID_IBaseFilter
  3. Add the VMR to the filter graph - by calling IGraphBuilder.AddFilter(IBaseFilter, "Your name of this filter in the graph")
  4. Query VMR for IVMRFilterConfig - by calling ObjCreateInterface passing IBaseFilter (VMR) object and IID_IVMRFilterConfig
  5. Set rendering mode to VMRMode_Windowless - by calling IVMRFilterConfig.SetRenderingMode(VMRMode_Windowless) - This is super important step!
  6. Query VMR for IVMRWindowlessControl - by calling ObjCreateInterface passing IBaseFilter (VMR) object and IID_IVMRWindowlessControl
  7. Assign the rendering window (desktop one) - by calling IVMRWindowlessControl.SetVideoClippingWindow(handle to the desktop window)
  8. Render video file - by calling IGraphBuilder.RenderFile(video file)
  9. Query IGraphBuilder for IBasicAudio, IMediaControl, IMediaSeeking and IMediaEvent interfaces - by calling ObjCreateInterface passing IGraphBuilder object and IID_IBasicAudio, then IID_IMediaControl, IID_IMediaSeeking and finally IID_IMediaEvent
  10. Call  IBasicAudio.put_Volume(-10000) to mute the video (just in case)
  11. Call IMediaSeeking.SetPositions(startTime, AM_SEEKING_AbsolutePositioning, endTime, AM_SEEKING_AbsolutePositioning)
  12. Run the graph - play video - by calling IMediaControl.Run()
  13. Wait until rendering stops - by calling IMediaEvent.WaitForCompletion(INFINITE,  ...)
  14. Finally grab the frame - by calling IVMRWindowlessControl.GetCurrentImage(pDIB)
  15. ...Do whatever with it (I'm writing it to the disk to a BMP file)
  16. Call CoTaskMemFree on pDIB

Simple right? Yes it is, the most boring and tedious is to write interfaces description strings, after that it's pure fun.

If you want to limit yourself to AVI files only then it might be good idea to use AVIFile..., AVIStream... functions from avifil32.dll for simplicity (if you would find that simple).

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
UEZ

Thanks for the answer and pseudo code. I need to dig first in how to use those interfaces and then let's see.

I will revert when I understood the object stuff and have any question. This can take a while (I'm over 40 ;))


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
wakillon

Do you suggest that trancexx is youngest than you ?

Would you have some other interesting informations ? :D


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
UEZ

Do you suggest that trancexx is youngest than you ?

Would you have some other interesting informations ? :D

​Afaik, yes she is younger than me.

I'm not an interesting person, rather boring. ;)


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
wakillon

I'm not an interesting person, rather boring. ;)

​No at all ! 

And i was asking about her ! :lol:


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
Lakes

Maybe this should be in the chat forum, (mods, move as required).

The mention of a true autoit compiler piqued my interest, now, I know you (trancex) can`t provide any details about this here, but some speed comparisons (a youtube video would be really nice) would be interesting to see.


2015 - Still no flying cars, instead blankets with sleeves.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • UEZ
      By UEZ
      AutoIt Windows Screenshooter
      Key Features:
      takes easily a screenshot from any visible window capture any region of the desktop incl. freehand capturing capture GUI controls and GUI menus separately capture a marked area every x seconds for a duration of y seconds create a GIF animation from saved frames (Vista or higher os required) capture to AVI file (without audio!) takes a screenshot from web sites (available only on Vista+ os and when Aero is enabled) put images to clipboard to paste to other applications easily color picker save image in different formats and also to PDF! add timestamp to saved images simple image editing options: greyscale, b&w, invert, rotate +-90° send image to printer and default email client preview of captured screens incl. zoom option multi monitor support display pixel color under mouse ruler basic image editor (paint, highlight, ellipse, rectangle, text and some graphic FX) watermark captured image no 3rd party tools or DLLs used - pure AutoIt! fully portable - no installation is needed multi language feature (Eng, Ger, Tur, Fra and Rus only) To do:
      capture content of scrollable window/control capture cascaded menus Due to DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) limitation some windows cannot be captured properly (GDI+, ProgDVB, etc.) but can take screenshots of hidden windows. One workaround is to use full screen capturing (F11/F12) or "Grab Screen" function! Or try double click with rmb on listview items (beta).
      Download source code (5771 downloads previously): AutoIt Windows Screenshooter v1.79 Build 2018-05-08.7z (version 3.3.12.0+ needed!)
      You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name!
      Download compiled Exe only: 4shared / Media Fire / Softpedia (1.54mb)
      Distributing copies of the program in compiled format (exe) must be free of any fee!
      -----> click here to Donate!  
       
      (Current donators: 1. Cuong N.) 
      It is designed for Vista+ operating systems with AERO enabled! E.g. on WinXP machines some functions are not working properly and might crash the application!
      AV scanners may have a negative impact the execution of compiled exe and might report any malware. I guarantee that there is no malicious code in the source code / exe!!! 
      Main GUI:

       
       
      About Intro:

       
       
      Basic Image Editor:

       
       
      Watermark:

       
       
      Click link for an enhanced version of Watermark Image.
      Credits:
      main code by UEZ additional code (alphabetical order) by Authenticity, AutoItObject Team, Eemuli, Eukalyptus, funkey, _Kurt, martin, monoceres, ProgAndy, taietel, trancexx, Ward, wolf9228 and Yashied! mesale0077 for turkish translation wakillon for french translation AZJIO for russian translation Keys:
      Main GUI:
      User your mouse to scroll preview window or
      Numpad 8: Scroll preview window up
      Numpad 2: Scroll preview window down
      Numpad 4: Scroll preview window left
      Numpad 6: Scroll preview window right
      Numpad +: zoom in preview window or mousewheel down
      Numpad -: zoom out preview window or mousewheel up
      F1: capture again on last position
      F5: refresh Windows Name list
      PRINTSCREEN: take screenshot from whole screen
      ALT+PRINTSCR: take a screenshot from active window
      F10: Undo made changes with Image Editing function
      F11: take screenshot from whole screen incl mouse cursor
      F12: take screenshot from whole screen
      Ctrl+Alt+F9 start "Grab Screen" mode
      Ctrl+Alt+F12: take a screenshot from active window using alternative screenshot functionality (beta)!
      Ctrl+r: call ruler
      Ctrl+s: save current displayed image
      Ctrl+x: exit program
      ctrl+w: call web grab input field (availabe only when Aero is enabled)
      Ctrl+i: call image editor
      Ctrl+m: call watermark editor
      Ctrl+z: undo
      Only available on Vista+ os: double click with rmb on list items to use alternative screenshot functionality (beta)!
      When 'Grab Screen' is clicked you can hold down the ctrl key to switch to 'grab controls' mode. Control under mouse will be framed red.
      ctrl + shift will take the screenshot of appropriate control. To capture GUI menues you can press rmb which simulates the lmb. When a menu is opened press shift additionaly to capture it.
      Press and hold only the shift key to capture any region on the desktop using freehand capturing - release it so capture marked regions!
      Or just mark resizeable area which you want to grab. Press CTRL key to grab marked area or right mouse button to capture the marked area every x seconds for a duration of y seconds.
      When saving the image just enter the extension you whish to use (*.jpg;*.png;*.bmp;*.gif;*.tif;*.pdf). Big thanks to taietel for his PDF UDF!
      Image Editor:
      s: save
      c: copy
      n: send
      h: highlighter
      p: pen
      r: rectangle
      e: ellipse
      a: arrow
      o: color
      t: text
      g: text config
      Ctrl+z: undo
      Watermark editor:
      Ctrl+z: undo
       
      To start the app minimized just call it "Windows Screenshooter.exe /min"
      Maybe it is useful for someone...
      Any kind of comment is welcome.
      Br,
      UEZ
      Change log:
       
    • CYCho
      By CYCho
       
      #include <GUIConstants.au3>
      #include <WindowsConstants.au3>

      Local $oPlayer, $gVideo, $width, $height
      $oPlayer = ObjCreate("WMPlayer.OCX.7")
      $oPlayer.URL = 'http://www.clubbalcony.com/upload/culture/yong(2).wmv'
      Local $srcFound = True
      Local $time1 = TimerInit()
      While 1
          If $oPlayer.playState() = 3 Then
              $width = $oPlayer.currentMedia.imageSourceWidth
              $height = $oPlayer.currentMedia.imageSourceHeight
              ExitLoop
          EndIf
          If TimerDiff($time1) > 5000 Then
              $srcFound = False
              ExitLoop
          EndIf
          Sleep(50)
      WEnd
      If Not $srcFound Or $width = 0 Then
          $oPlayer.Close()
          Exit
      Else
          $gVideo = GUICreate("Video Control", $width, $height+63, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX), $WS_EX_TOPMOST)
          GUICtrlCreateObj($oPlayer, 0, 0, $width, $height+63)
          $oPlayer.uiMode = "Full"
          $oPlayer.stretchToFit = True
          GUISetState(@SW_SHOW, $gVideo)
      EndIf

      While 1
          $Msg = GUIGetMsg(1)
          Switch $Msg[0]
              Case $GUI_EVENT_CLOSE
                  ExitLoop
              Case $GUI_EVENT_RESIZED
                  ;This is where I want to resize the video image to fit the new window size
          EndSwitch
      WEnd
      $oPlayer.Close()
         
      How should I code the $GUI_EVENT_RESIZED portion to resize the video to fit the resized window? Your help will be greatly appreciated.

       
    • Earthshine
      By Earthshine
      This baby can do almost any language! I found Gleany on this site and set it up on a fresh win10 install. all i would need to do to make it build an exe of the search files app we discovered is the .NET Target Framework download to build 100 % but the exe works and generates! You also need to add the path the the version of csc.exe that you want to run. MSBuild is part of .NET and can read your .csproj file.
      YOU can develop .NET OR C/C++ on this baby!
      Super lightweight (fit for crappy laptops), and you can use any dev compilers you wish, Ming, MS, etc, whatever.
      To use the build, you need to open the csproj file, else, to check your syntax it can compile individual files as well. The warning are because I do not have the .NET 4.6 Targeting Pack installed... LOL, and I could get rid of the Core warning, yes, I did not want to build a .NET Core.dll I wanted a live x64 exe! Told you MSBUILD could handle .CSPROJ, .VBPROJ, and all others Microsoft. Don't let Visual Code or Visual Studio slow you down, although, this works with Visual Code as well but there is only debugging in CORE.DLL projects

      ListFiles Example.zip
       

    • Luigi
      By Luigi
      Greetings, someone can give a exemple, how send a error from a C#'s dll to AutoIt?
      I use this line, to send an error... but, I want get a error code In AutoIt with macro @error, it's possible?
       
      throw new ArgumentException("arquivo map não existe", "value" ); In this way, work, I know ther are error, but, @errror always is zero.
      I don't want this, I want a number as error code.
      Can you help me?
       
      Best regards
    • nss
      By nss
      Hi all,
       
      I am making a program in which I use Bass audio library (with the wrapper for autoit that I found here on forums I think) because of its support for dx effects.
      My problem, though, is that when effects as reverb or echo/delay are added, the channel length is not extended as to fit the tail of the effect, so if the file was really short, you wouldn't even hear the reverb at all.
      I've tried setting the  buffer parameter even to 60k ms, updating the channel length to 60k ms, but nothing makes it so that the effects aren't being cut off.
      I've heard that I could add silence manually to wave files by adding the chr(0) characters, but haven't had any luck doing that, either.
      What I'm doing:
      initialize bass use streamCreateFile to load the wave file with the fx flag and length parameter set to 60000 set the config buffer to 60000 use channel set fx to add dx8 reverb use channel play to play the sound use bass update to update the length to 60000  
      I even tried having only silence in one wave file and tried joining two wave files together, but that didn't work either.
       
      Any help would be very much appreciated.
×