Jump to content

AVI writing udf


monoceres
 Share

Recommended Posts

Yep, 7 months later and I finally did it!

It's a UDF for creating uncompressed avi:s from bitmap files (support for compressing the video, may or may not appear). :)

The structure is very easy:

  • Start the avi library
  • Create a avi file
  • Add bitmaps to it
  • Close the avi
  • Stop the avi library
Download:

AVIWriter.au3

Previous downloads: 55

Example:

; Example by ProgAndy
#include <ScreenCapture.au3>
#include "AVIWriter.au3"

Hotkeyset("{ESC}","close")

Break(0)


FileDelete(@DesktopDir & "\test.avi")

_StartAviLibrary()

$avi = _CreateAvi(@DesktopDir & "\test.avi", 5,200,200)

Do
    $m = MouseGetPos()
    $hBmp = _ScreenCapture_Capture("", $m[0] - 100, $m[1] - 100, $m[0] + 100, $m[1] + 100, True)
    _AddHBitmapToAvi($avi, $hBmp)
    _WinAPI_DeleteObject($hBmp)
    Sleep(200)
Until False



Func close()
    _CloseAvi($avi)
    _StopAviLibrary()
    exit
EndFunc;==>close

Enjoy! :o

Link to FireFox's AviScreencapture tool that relies on this udf.

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

@monoceres

Yep, 7 months later and I finally did it!

For 4.11 Ko ? Its a joke ?

Nice work :D I like it :)

Edit : Colors in avi are not same as in bitmap : compressed ? I dont think with 23Mo for 40sec but its good way to do it in AutoIt :D

This can be used for manythings : 5stars for me (keep it up) :o

Edit : I think this was for udf ?

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

@monoceres

For 4.11 Ko ? Its a joke ?

Unfortunately not. I've picked up the project at multiple times but never been able to get past some difficulties with the bitmaps. I also didn't realize I could use the bitmap header as the format for the avi stream. I've always tried to create a compressed stream, something I still haven't been able to figure out.

Nice work :D I like it :)

Edit : Colors in avi are not same as in bitmap : compressed ? I dont think with 23Mo for 40sec but its good way to do it in AutoIt :D

This can be used for manythings : 5stars for me (keep it up) :o

Edit : I think this was for udf ?

Cheers, FireFox.

Thanks :D

Would you mind uploading a sample bitmap and avi? Oh and what player are you using? The videos don't work in vlc for me but do in media player classic.

Edit: Yeah, that was me asking for help with this udf.

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Would you mind uploading a sample bitmap and avi? Oh and what player are you using? The videos don't work in vlc for me but do in media player classic.

Hum... this work for me with vlc :) I will try with other avi players and I will upload for you sample bitmap and avi

Cheers, FireFox.

Link to comment
Share on other sites

@monoceres

Vlc reverse some colors but with windows media player this works great !

<snipped deprecated urls>

btw : I think that you can do like hypercam program... with parameters (selecting area etc...)

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

@monoceres

Vlc reverse some colors but with windows media player this works great !

Uploaded bmp : http://d3monautoit.free.fr/capture.bmp

Uploaded avi : http://d3monautoit.free.fr/test.avi

btw : I think that you can do like hypercam program... with parameters (selecting area etc...)

Cheers, FireFox.

Well yeah. Nothing odd about the files. So I guess it's vlc fault (or my sloppy avi writing).

Anyways, as you noticed the file size grows very fast so one should probably use a cli video encoder like ffmpeg to create usuable video files.

And yeah, a hypercam program could be done quite easily with this :)

Edit:

@FireFox: You've got the wrong idea. This works only with uncompressed bitmaps, due to how you set the stream in the avi and how each frame is served to the avi file.

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Edit:

@FireFox: You've got the wrong idea. This works only with uncompressed bitmaps, due to how you set the stream in the avi and how each frame is served to the avi file.

Hmm.... yeah, use compression dll would be better as soon as video is finished; like other programs do :)

Cheers, FireFox.

Link to comment
Share on other sites

I have a little problem with this:

_StartAviLibrary()
            $FILE = _FileListToArray(@ScriptDir,"*.BMP",1)
            If IsArray($FILE) Then
                $FOLDER = @ScriptDir & "\"
                $AVI = _CreateAvi(@ScriptDir & "\AVI_File.avi",5,$PATH & $FILE[1])
                For $INDEX = 2 To $FILE[0]
                    _AddBitmapToAvi($AVI,$PATH & $FILE[$INDEX])
                Next
            _CloseAvi($AVI)
            _StopAviLibrary()

And I got this error: _WinAPI_CloseHandle: The operation completed successfully

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

I have a little problem with this:

_StartAviLibrary()
             $FILE = _FileListToArray(@ScriptDir,"*.BMP",1)
             If IsArray($FILE) Then
                 $FOLDER = @ScriptDir & "\"
                 $AVI = _CreateAvi(@ScriptDir & "\AVI_File.avi",5,$PATH & $FILE[1])
                 For $INDEX = 2 To $FILE[0]
                     _AddBitmapToAvi($AVI,$PATH & $FILE[$INDEX])
                 Next
             _CloseAvi($AVI)
             _StopAviLibrary()

And I got this error: _WinAPI_CloseHandle: The operation completed successfully

I assume $PATH doesn't have a trailing "\" so when you're passing $PATH&$FILE[n] you need to have a "\" between them.

Oh and note that $FILE[1] won't appear in the video. The bitmap you pass to _CreateAVI() is only used to determine the format of the stream.

:)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

I assume $PATH doesn't have a trailing "\" so when you're passing $PATH&$FILE[n] you need to have a "\" between them.

Oh and note that $FILE[1] won't appear in the video. The bitmap you pass to _CreateAVI() is only used to determine the format of the stream.

:)

Thanks monoceres. I changed a little your example, hope you like.

#include <ScreenCapture.au3>
#include <AVIWriter.au3>
#include <Process.au3>

Hotkeyset("{ESC}","close")

Break(0)

$X = @DesktopWidth
$Y = @DesktopHeight
_StartAviLibrary()
_ScreenCapture_Capture("capture.bmp",0,0,$X,$Y,True)
$AVI = _CreateAvi("test.avi", 5,"capture.bmp")


Do
    _ScreenCapture_Capture("capture.bmp",0,0,$X,$Y,True)
    _AddBitmapToAvi($AVI, @ScriptDir & "\capture.bmp")
    Sleep(200)
Until False



Func close()
    _CloseAvi($AVI)
    _StopAviLibrary()
    CompressAVI("test.avi")
    exit
EndFunc ;==>close

Func CompressAVI($PATH)
    _RunDOS('ffmpeg -i test.avi -b 512k -vcodec msmpeg4v2 Compressed_AVI.avi')
EndFunc

FFMPEG

When the words fail... music speaks.

Link to comment
Share on other sites

@Andreik

Change little your example

#include <ScreenCapture.au3>
#include <AVIWriter.au3>
#include <Process.au3>

HotKeySet("{ESC}", "close")

Break(0)

$X = @DesktopWidth
$Y = @DesktopHeight
_StartAviLibrary()
_ScreenCapture_Capture("capture.bmp", 0, 0, $X, $Y, True)
$AVI = _CreateAvi("test.avi", 5, "capture.bmp")


Do
    _ScreenCapture_Capture("capture.bmp", 0, 0, $X, $Y, True)
    _AddBitmapToAvi($AVI, @ScriptDir & "\capture.bmp")
    Sleep(200)
Until False



Func close()
    _CloseAvi($AVI)
    _StopAviLibrary()
    CompressAVI("test.avi")
    Exit
EndFunc   ;==>close

Func CompressAVI($PATH)
    TrayTip("AVIWritter", "Compressing avi...", 3, 4)
    _RunDOS('ffmpeg -i test.avi -b 512k -vcodec msmpeg4v2 Compressed_AVI.avi')
    TrayTip("AVIWritter", "Finished !", 3, 4)
EndFunc   ;==>CompressAVI

Cheers, FireFox.

Link to comment
Share on other sites

That's a nice start FireFox :) However you still cannot save the captured frames as anything else than .bmp. It just how the UDF work.

Thanks :o

Huh? Cant do it better for add more picture extensions ?

We'll have to find better compression...

Cheers, FireFox.

Link to comment
Share on other sites

@NerdFencer

??? Why ???

Look at source code, frames are only screenshots with _ScreenCapture_Capture and I think you can do it yourself or....

Function for write all screenshots in a folder ?

Cheers, FireFox.

I think he want pictures from AVI not especially screenshots. Maybe he used this AVI functions to do something else, like a short clip based on 50 pictures and now he want to extract picture 21.

I hope that I`m not wrong. :)

When the words fail... music speaks.

Link to comment
Share on other sites

I have seen examples on the net for extracting bitmaps, however it only works on uncompressed avi's which kinda limits the usefulness.

I'll look into sound as well, as far as I understand it's just another stream (however I kinda suspect it will be uncompressed audio as well).

Oh and FireFox, I think it would be better if you support your app in you own thread. I'll ask a mod if he can break out the posts concerning your app :)

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

@monoceres

Sorry for have spamming your udf i thought it was nice idea to make an example but i went to far and made app with it :)

You didnt have to call mod but now its done... anyway thanks :o

And the most important is to keep it up ! :D

Cheers, FireFox.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...