Jump to content
Sign in to follow this  
Audrey

JPG to AVI

Recommended Posts

Audrey

Hi Guys,

There are some topics about the writing AVI files with your webcam and screencapture, but I can't find any about converting JPG to AVI.

I took a look of this UDF but thats for capturing the screen only.

So, I have lets say 10 frames on the desktop, 1.JPG, 2.JPG, 3.JPG, ....

They have to be converted to an AVI file and saved to the desktop as well.

I changed the code of the link above, but its not working.

So I think I missed a extra line in my script to add the right JPG or format.

My code:

; Example by ProgAndy
#include "AVIWriter.au3"

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

Break(0)

Global $count, $hBmp


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

_StartAviLibrary()

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

For $count = 1 to 10

    $hBmp = @DesktopDir & "\" & $count & ".jpg"
    _AddHBitmapToAvi($avi, $hBmp)
    _WinAPI_DeleteObject($hBmp)
    Sleep(200)

next


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

Can anyone help me with this?

All the best,

Audrey

Edited by Audrey

Share this post


Link to post
Share on other sites
monoscout999

I dont know very well the AVIWriting UDF, but you are passing an String and not a Bitmap handle like the AVIWriting Example...

I failed trying to get the hBmp From the jpg files, maybe someone else can help you.

Share this post


Link to post
Share on other sites
Audrey

Hi Scout,

Thanks for the reply!

You are right, my suggestion is wrong.

Now I added some GDIplus functions. Maybe this will bring us back on the road...

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

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

Break(0)

Global $count, $hBmp


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

_StartAviLibrary()

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

For $count = 1 to 10

    $hImage = _GDIPlus_ImageLoadFromFile( @DesktopDir & "\" & $count & ".jpg")
    $hBmp = _GDIPlus_ImageGetGraphicsContext($hImage)
    _AddHBitmapToAvi($avi, $hBmp)
    _WinAPI_DeleteObject($hBmp)
    Sleep(200)

next

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

Greets,

Audrey

Edited by Audrey

Share this post


Link to post
Share on other sites
Armenxxx1

#include "AVIWriter.au3"
#include <GDIPlus.au3>

Global $count, $hBmp

_StartAviLibrary()
_GDIPlus_Startup()

$hImage = _GDIPlus_ImageLoadFromFile(@DesktopDir & "\aaz\1.jpg")
$Width = _GDIPlus_ImageGetWidth($hImage)
$Height = _GDIPlus_ImageGetHeight($hImage)


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

For $count = 1 to 100
   $hImage = _GDIPlus_ImageLoadFromFile(@DesktopDir & "\aaz\" & $count & ".jpg")
   $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)

    _AddHBitmapToAvi($avi, $hBmp)
    _WinAPI_DeleteObject($hBmp)
    Sleep(100)
next

_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($hBmp)
_GDIPlus_Shutdown()
_CloseAvi($avi)
_StopAviLibrary()
exit

  • Like 1

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.