Is this right?
AVISTREAMINFO struct
fccType dword 0
fccHandler dword 0
dwFlags dword 0
dwCaps dword 0
wPriority word 0
wLanguage word 0
dwScale dword 0
dwRate DWORD 0
dwStart DWORD 0
dwLength DWORD 0
dwInitialFrames DWORD 0
dwSuggestedBufferSize DWORD 0
dwQuality dword 0
dwSampleSize dword 0
rcFrame RECT <0>
dwEditCount dword 0
dwFormatChangeCount dword 0
szName dword [64]
AVISTREAMINFO ends
iAVIFILE struct
CreateStream dword 0
EndRecord dword 0
GetStream dword 0
Info dword 0
Open dword 0
ReadData dword 0
WriteData dword 0
iAVIFILE ends
TAviUtil struct
pfile dword 0
wfx WAVEFORMATEX <0>
period dword 0
as dword 0
ps dword 0
psCompressed dword 0
nframe dword 0
nsamp dword 0
iserr dword 0
TAviUtil ends
AVICOMPRESSOPTIONS struct
fccType dword 0
fccHandler dword 0
dwKeyFrameEvery dword 0
dwQuality dword 0
dwBytesPerSecond dword 0
dwFlags dword 0
lpFormat dword 0
cbFormat dword 0
lpParms dword 0
cbParms dword 0
dwInterleaveEvery dword 0
AVICOMPRESSOPTIONS ends
.code
fCreateAVI proc uses esi edi lpFileName:dword,nFramePeriode:dword,wfx:dword
LOCAL au:dword
invoke fvAVIFileInit
invoke mAlloc,sizeof TAviUtil
mov esi,eax
invoke fvAVIFileOpen,addr [esi].TAviUtil.pfile,lpFileName,OF_WRITE or OF_CREATE,0
.if eax!=0
invoke fvAVIFileExit
ret
.endif
lea edx,[esi].TAviUtil.wfx
invoke memfill,edx,sizeof WAVEFORMATEX,0
push nFramePeriode
pop [esi].TAviUtil.period
push 0
pop [esi].TAviUtil.as
push 0
pop [esi].TAviUtil.ps
push FALSE
pop [esi].TAviUtil.iserr
mov eax,esi
ret
fCreateAVI endp
fAddFrame proc uses esi edi avi:dword,hbmp:dword,hWnd:dword
LOCAL stdhdr:AVISTREAMINFO
LOCAL b:DIBSECTION
LOCAL op:AVICOMPRESSOPTIONS
LOCAL r:RECT
LOCAL buff[256] :dword
invoke GetObject,hbmp,sizeof DIBSECTION ,addr b
invoke memfill,addr stdhdr,sizeof stdhdr,0
mov esi,avi
.if [esi].TAviUtil.ps==0
push "SDIV"
pop stdhdr.fccType
push 0
pop stdhdr.fccHandler
push [esi].TAviUtil.period
pop stdhdr.dwScale
push 1000
pop stdhdr.dwRate
push b.dsBmih.biSizeImage
pop stdhdr.dwSuggestedBufferSize
invoke SetRect,addr stdhdr.rcFrame,0,0,b.dsBmih.biWidth,b.dsBmih.biHeight
invoke fvAVIFileCreateStream,[esi].TAviUtil.pfile,addr [esi].TAviUtil.ps,addr stdhdr
.if eax!=0
invoke PERR
.endif
.endif
.if [esi].TAviUtil.psCompressed==0
invoke memfill,addr op,sizeof AVICOMPRESSOPTIONS,0
mov eax,"XVID"
;bswap eax
mov op.fccHandler,eax
;----------------------------------------------------------------------------------------------------------------------------------
; SOMETHING WAS WRONG HERE
invoke fvAVIMakeCompressedStream,addr [esi].TAviUtil.psCompressed,[esi].TAviUtil.ps,addr op,0
; .if eax!=0
; mov ecx,eax
; invoke dw2hex,ecx,addr buff
; invoke SetWindowText,hWnd,addr buff
; .endif
invoke dw2hex,[esi].TAviUtil.psCompressed,addr buff
invoke SetWindowText,hWnd,addr buff
ret
;-------------------------------------------------------------------------------------------------------------------
mov ecx,b.dsBmih.biClrUsed
shl ecx,2
add ecx,b.dsBmih.biSize
invoke fvAVIStreamSetFormat,[esi].TAviUtil.psCompressed,0,addr b.dsBmih,ecx
.if eax!=0
invoke PERR
.endif
.endif
invoke AVIStreamWrite,[esi].TAviUtil.psCompressed,[esi].TAviUtil.nframe,1,b.dsBm.bmBits,b.dsBmih.biSizeImage,AVIIF_KEYFRAME,0,0
.if eax!=0
invoke PERR
.endif
inc [esi].TAviUtil.nframe
ret
fAddFrame endp
fCloseAVI proc uses esi edi hAvi:dword
LOCAL buff[256]:dword
mov esi,hAvi
.if [esi].TAviUtil.as!=0
invoke fvAVIStreamRelease,[esi].TAviUtil.as
.endif
mov [esi].TAviUtil.as,0
.if [esi].TAviUtil.psCompressed!=0
invoke fvAVIStreamRelease,[esi].TAviUtil.psCompressed
.endif
mov [esi].TAviUtil.psCompressed,0
.if [esi].TAviUtil.pfile !=0
invoke fvAVIFileRelease, [esi].TAviUtil.pfile
.endif
mov [esi].TAviUtil.pfile,0
invoke fvAVIFileExit
invoke GlobalFree,esi
ret
fCloseAVI endp
The original code is here http://www.wischik.com/lu/programmer/avi_utils.html
Not just doesnot write anything also, the close avi file is crashed.
[edit]Oke got it working[/edit]
It seems the avifil32.lib is broken, can somebody do something?
Anyone can point where is my mistake? When I used the XVID codec it access a wrong memory address, it point to 0 and I dont know why.
Oke I got it working, but there are problem here, the header is blank, the first 2kb part is filled with 0, dont know where is my mistake is.
For those who want to experimenting, I uploaded the include file.
How to Use
.data
vw dword 0
.code
.elseif WM_CREATE
invoke fCreateAVI,CADD("test.avi"),1000/20,0
mov vw,eax
; How to Add Frame
invoke fAddFrame,vw,fb.bmp,hWnd
; How to Close and Save
invoke fCloseAVI,vw
If this code works on your system, it mean, I installed a bad codecs.
@ Everyone: THIS APP IS VERY UNSAFE.... I will delete this message after Farabi has tested app if I have access rights, it is just a test app to help with this topic, sorry no code either, this is just an Alpha test :P
Hey Farabi,
Follow instructions in pm carefully, as I said very dodgy build nothing is checked so will error all over the place if not setup exactly as pm
EDIT: lol only 8 downloads
Thanks I've downloaded it.
No luck, it crashes.
hmm if you had folders/files etc setup in pm as I said I dont know why.... those folders / files must be in c drive and must exist.... If I get a chance today I'll add error checking for you
OK again possibly rushed and dodgy code but some limited error checking now and additional checking files:
put the folder 'bmps' in the c:\ drive and run the app.... it should bring up a format dialog and then create c:\test.avi
it does work, but not with all the codecs
ah yes I should have said that.... I have the same issue.... I dont know why yet but it does work with some (Microsoft 1) for example for me and uncompresed
i use the k-lite mega codec pack
it works with ffdshow :bg
but not xVid or DivX :(
for those, it creates the AVI, but only 1 of the 2 frames show up
What is a good generic format? It's all very well creating with better codecs but like image formats you want something that's also universally accepted
PS. Yes my cartoon skills are for hire but you probably cant afford me :lol
i don't know about the word "generic" - lol
but DivX and xVid are the formats of choice
they create a good quality video with good compression (xVid probably the best)
i think those 2 formats are very similar, so if you get one working, the other will probably follow
don't feel bad - i can't draw, either
but, i can write a program to do it for me :bg
Dave:
That was my problem too. On mine the avi had no header. I guess it was a common problem.
surprise !
it actually does work with DivX and xVid - kinda - lol
for both of these formats, the last frame is not displayed for some reason
the first frame is displayed longer than the rest
for xVid, the frame rate seems to change - very odd - must have something to do with the compression technique
i made 30 frames and numbered some of them
you can make an AVI using the different codecs to see the different results...
i played with some settings and got it to work with xVid :P
(http://img52.imageshack.us/img52/5757/xvid.jpg)
Note:
szName dword [64]
should be:
szName WORD 64 DUP (0)
AVISTREAMINFO struct
fccType dword 0
fccHandler dword 0
dwFlags dword 0
dwCaps dword 0
wPriority word 0
wLanguage word 0
dwScale dword 0
dwRate DWORD 0
dwStart DWORD 0
dwLength DWORD 0
dwInitialFrames DWORD 0
dwSuggestedBufferSize DWORD 0
dwQuality dword 0
dwSampleSize dword 0
rcFrame RECT <0>
dwEditCount dword 0
dwFormatChangeCount dword 0
szName WORD 64 DUP (0)
AVISTREAMINFO ends
can you define the PERR function please Farabi, also oex whats the point of uploading a binary with no source, when hes asking for help on his code?
Quote from: E^cube on September 17, 2010, 07:01:05 AM
can you define the PERR function please Farabi
This post is old and fixed I believe but I noticed this evening the structure was in error
Quote from: E^cube on September 17, 2010, 07:01:05 AM
also oex whats the point of uploading a binary with no source, when hes asking for help on his code?
The binary contained much junk code and macros it was a rip from one of my apps so it was less confusing to test that the dlls were working as expected with a binary I was also on chat to Onan via YIM for the code but it was convenient to upload this binary via the forum....
:lol my code doesnt follow MASM syntax, too many automation macros for it to make much sense for quick fixes and this was quite a lot of code to manually convert
well farbi's code crashes, I managed to get it to assemble after jacking include files from http://www.masm32.com/board/index.php?PHPSESSID=9cff7ea2a9244fc89e79c01671bb51d0&topic=6315.0 and defining the few missing functions. He forgot to call invoke fVideoInitin the example too which was probably the reason for the 0's address error. But now it crashes somewhere inside xvid module, so whatever, I guess he went with your code?
Quote from: E^cube on September 17, 2010, 07:23:31 AM
I guess he went with your code?
Yeah I think we got it fixed in the end via chat, the AVI code is a pain, I just noticed that structure bug tonight using another function in the set and it caused me all sorts of grief identifying that issue there are no error codes :lol
Quote from: oex on September 17, 2010, 07:26:08 AM
Quote from: E^cube on September 17, 2010, 07:23:31 AM
I guess he went with your code?
Yeah I think we got it fixed in the end via chat, the AVI code is a pain, I just noticed that structure bug tonight using another function in the set and it caused me all sorts of grief identifying that issue there are no error codes :lol
well if you or him ever wanna upload the fixed code here, you're welcome to :U now that you and Farabi have intrigued the whole forum
The original code is here: http://www.wischik.com/lu/programmer/avi_utils.html (In Onan's first post) I think the code is almost right but I cant remember what we found the error to be now it might have been specifying bad compression options.... The binary I posted works but was using a different method to test the same result, I dont have that code anymore it was just a temp build