so here are my sources.
the first on is a skeleton of a program that extracts first x frames from an AVI file. it works OK. the full source is in the attachment. You just have to change "moviename" in the source to some avi file of yours.



.data
moviename db "c:\movies\40 40\The Prodigy - Out Of Space.mpg.avi",0

.data?
hmovie dd ?
streami dd ?
bimpinfo BITMAPINFOHEADER <>
getframe dd ?
framenow dd ?

.code
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_USER+1
;opening file
ii AVIFileOpen,addr hmovie,addr moviename,OF_SHARE_DENY_WRITE or OF_READ,0
.if !eax
;get video stream
ii AVIFileGetStream,hmovie,addr streami,streamtypeVIDEO,0
.if !eax
;fill "bimpinfo" which is a BITMAPINFOHEADER with proper width and stuff
;...
;start getting frames
ii AVIStreamGetFrameOpen,streami,addr bimpinfo
.if eax
mov getframe,eax
mov framenow,0
.repeat
ii AVIStreamGetFrame,getframe,framenow
.if eax
;if eax is not NULL it points to a DIB. I can write it to disk, print on screen or whatever
.endif
inc framenow
.until framenow==30

;cleaning
ii AVIStreamGetFrameClose,getframe
.endif

ii AVIStreamRelease,streami
.endif
ii AVIFileRelease,hmovie
.endif



and here is the second one:
it should extract first seconds of audio and write them, but it doesn't.
i dont know what is the last parameter in AVIMakeCompressedStream function so I set it to zero.



.data
moviename db "c:\movies\40 40\The Prodigy - Out Of Space.mpg.avi",0
desting WAVEFORMATEX <1,2,44100,44100*4,4,16,0>
.data?
hmovie dd ?
fileboxes dd 256 dup (?)

streami dd ?
streaminfo AVISTREAMINFO <>
streamname db (sizeof AVISTREAMINFO.szName+1) dup (?)

deststream dd ?
aco AVICOMPRESSOPTIONS <>


.code
ii AVIFileOpen,addr hmovie,addr moviename,OF_SHARE_DENY_WRITE or OF_READ,0
.if !eax
ii AVIFileGetStream,hmovie,addr streami,streamtypeAUDIO,0
.if !eax
mov aco.fccType,streamtypeAUDIO
mov aco.fccHandler,0
mov aco.dwKeyFrameEvery,0
mov aco.dwQuality,0
mov aco.dwBytesPerSecond,0
mov aco.dwFlags,0 ; AVICOMPRESSF_VALID
mov aco.lpFormat,offset desting
mov aco.cbFormat,sizeof desting
mov aco.lpParms,0
mov aco.cbParms,0
mov aco.dwInterleaveEvery,0

ii AVIMakeCompressedStream,addr deststream,streami,addr aco,0
.if !eax
seconds equ 1
;ii AVIStreamRead,streami,0,44100*seconds,0,0,addr readbytes,addr readsamples
ii AVIStreamRead,deststream,0,44100*seconds,0,0,addr readbytes,addr readsamples
.if !eax
.if readbytes
;make buffer
;...
;read
;ii AVIStreamRead,streami,0,44100*seconds,eax,ecx,addr readbytes,addr readsamples
ii AVIStreamRead,deststream,0,44100*seconds,eax,ecx,addr readbytes,addr readsamples
.endif
.endif
ii AVIStreamRelease,deststream
.endif
ii AVIStreamRelease,streami



It works until the second AVIStreamRead func which returns FILE_READ_ERROR or sth

in attached zip there are full sources. you have to extract all to your masm32 dir (because of macros and includes)
Posted on 2003-07-03 11:22:58 by stolarz