You can download the Dll and the source (developed with PB 4.10)
at: http://www.sunset-team.de/Download/AVIServ.zip [18 kB]
Please remind, the dll is still in beta status and unchanged since 2007...
Code: Select all
; How to use it
; 2 examples AVI2BMP, BMP2AVI
Structure AVI_INFO
aviWidth.l
aviHeight.l
aviFirstFrame.l
aviNumFrames.l
aviFPS.b
hWnd.l
EndStructure
Enumeration
#Lib
EndEnumeration
UseJPEGImageDecoder()
Procedure AVI2BMP ()
file.s = OpenFileRequester( "Open AVI", "D:\Database\Sources\ST_Soft\AVI\", "AVI Video|*.avi", 0 )
*INF.AVI_INFO = CallFunction( #Lib, "OpenAVIforRead", file.s )
If *INF
MessageRequester( "AVI Stream Info", "Size: " + Str(*INF\aviWidth) + "x" + Str(*INF\aviHeight) + Chr(13) + "Frames: " + Str(*INF\aviNumFrames), 0 )
hBmp = CreateImage ( 0, *INF\aviWidth, *INF\aviHeight )
For a = *INF\aviFirstFrame To *INF\aviNumFrames - *INF\aviFirstFrame - 1
If CallFunction( #Lib, "GetFrameFromAVI", hBmp, a )
SaveImage(0, "Sequence_" + Right("000" + Str(a), 4 ) + ".bmp" )
Else
MessageRequester( "FrameGet error", "DIB class can only handle unpalletized memory DIBs - RGB 16 or 24bit color", #MB_ICONEXCLAMATION | #MB_OK )
a = *INF\aviNumFrames + 1
EndIf
Next
CallFunction( #Lib, "CloseAVIStreams" )
MessageRequester( "Done", "AVI splitted to bitmaps", 0 )
Else
MessageRequester( "Error", "Could not open avi", 0)
EndIf
EndProcedure
Procedure BMP2AVI ()
INF.AVI_INFO
INF\hWnd = OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Images 2 AVI" )
If INF\hWnd And CreateGadgetList( INF\hWnd )
ListViewGadget( 0, 0, 0, 300, 200 )
file.s = SaveFileRequester( "Save AVI", "", "AVI Video|*.avi", 0 )
dir.s = PathRequester( "Select images directory", GetPathPart( file.s ))
If ExamineDirectory( 0, dir.s, "*.*" )
Repeat
Res = NextDirectoryEntry()
If Res = 1
img.s = DirectoryEntryName()
ext.s = UCase(GetExtensionPart(img.s))
If ext = "BMP" Or ext = "JPG" Or ext = "JPEG"
hBmp = LoadImage(0, dir + img )
If hBmp
If INF\aviWidth <= 0
INF\aviWidth = ImageWidth()
INF\aviHeight = ImageHeight()
INF\aviFPS = 1 ; Play 1 Frame per Second
SetForegroundWindow_( INF\hWnd )
If CallFunction( #Lib, "OpenAVIforWrite", file.s, @INF ) = #False : Res = 0 : EndIf
EndIf
If INF\aviWidth + INF\aviHeight <> ImageWidth() + ImageHeight()
hBmp = ResizeImage( 0, INF\aviWidth, INF\aviHeight )
EndIf
If INF\aviWidth
StartDrawing( ImageOutput() )
; Make some image effects ...
DrawingMode( 1|2 )
Locate (1, 1) : DrawText( "PureBasic RuLeS! :-)" )
Locate (INF\aviWidth - TextLength( img ) - 10, INF\aviHeight - 20 ) : DrawText( img )
StopDrawing()
If CallFunction( #Lib, "AddFrameToAVI", hBmp, -1 ) = #True ; -1 Autoincrement FrameNr
Frames + 1
EndIf
EndIf
Else
img + " failed"
EndIf
AddGadgetItem( 0, -1, img )
EndIf
EndIf
Until Res = 0
AddGadgetItem(0, -1, "Done. " + Str(Frames) + " Images." )
CallFunction( #Lib, "CloseAVIStreams" )
Repeat : Until WaitWindowEvent() = #PB_EventCloseWindow
EndIf
EndIf
EndProcedure
If OpenLibrary( #Lib, "AVIServ.dll" )
If CallFunction( #Lib, "AVI_Init" )
AVI2BMP() ; Splitt AVI video into singel frames
;BMP2AVI() ; Create AVI and add *jpg, *bmp images
CallFunction( #Lib, "AVI_Quit" )
EndIf
CloseLibrary( #Lib )
Else
MessageRequester( "Error", "Could not open AVIServ.dll", 0)
EndIf
End
cya dige