Jump to content

JPG to AVI


Recommended Posts

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

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

  • 1 year later...

#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

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...