AVI capture.

Windows specific forum
TIGER
User
User
Posts: 81
Joined: Mon Feb 23, 2004 8:33 pm

AVI capture.

Post by TIGER »

Hi giys.
I was able to play AVI file frime by frame using API only.
But i cant capture the frame.
From window point by point it slow and image is corrupded.
Is theri is a way to get to frame data using API.
Or that information must be somwhere in the memory.
PLEASE HELP !

Code: Select all

OpenLibrary(0,"winmm.dll")
width.l=512 ;width of window
height.l=384 ;and the height
mType.s="AviVideo"
statusBuf.s=""
filename.s="shrek.avi" ;the avi file name goes here
command.s=""

OpenWindow(0,0,0,width,height,#PB_Window_ScreenCentered,"",0)

CreateGadgetList(WindowID(0))
TextGadget(1,0,0,width,height,"ljl")


command="open "+Chr(34)+filename+Chr(34)+" type "+mType+" alias sfx" 
CallFunction(0,"mciSendStringA",command,"",0,0) 


hw1=GadgetID(1)
command = "window sfx handle " + Str(hw1)
CallFunction(0,"mciSendStringA",command,"",0,0) 
CallFunction(0,"mciSendStringA","put sfx destination at 0 0 "+Str(width)+" "+Str(height),"",0,0) 




CallFunction(0,"mciSendStringA","set sfx time format frames" ,"",0,0) 
CallFunction(0,"mciSendStringA","info sfx file wait",statusBuf,254,0) 
CallFunction(0,"mciSendStringA","status sfx length",statusBuf,254,0)
playLength=Val(statusBuf) 



For r=0 To 50
Delay(1)
WindowEvent()
CallFunction(0,"mciSendStringA","play sfx from "+Str(r)+" To "+Str(r),"",0,0)
Next r


CallFunction(0,"mciSendStringA","close all","",0,0)





















CloseWindow(0)
CloseLibrary(0)

PIII450 128RAM TNT2
User avatar
J. Baker
Addict
Addict
Posts: 2192
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

Have you tried pause frame before capture?
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
TIGER
User
User
Posts: 81
Joined: Mon Feb 23, 2004 8:33 pm

Post by TIGER »

I am not sure what you mean.

I tryed to use
CallFunction(0,"mciSendString","Save AVIFile c:\try.tga","",0,0)
Bud i didnt tryed to pause the frame.

I make if freese onother way before capturing.
Using TO command in mciSendString.

You know API, i have to pause the frame with pause function
otherwise it not work ?
PIII450 128RAM TNT2
User avatar
J. Baker
Addict
Addict
Posts: 2192
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

No, I haven't used too much api myself but I have noticed some webcam software where there is a pause before frame capture. I think still screen is easier to capture then motion. With motion you might have to learn about plug-ins that play back the video before you can capture a frame, such as direct show. Hope this helps you. I'll try to look into this more tonight.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

you can try this and maybe tweak it to capture your window.
this will capture your desktop



Code: Select all

Global Left.l
Global Top.l
Global Width.l
Global Height.l
Global DeskTopSprite.l
Global DeskTop.l

Procedure.l CaptureDesktop(Left2.l, Top2.l, Width2.l, Height2.l) 
    ; make a copy of the desktop image, press printscreen
    dm.DEVMODE 
    BMPHandle.l 
    srcDC = CreateDC_("DISPLAY", "", "", dm) 
    trgDC = CreateCompatibleDC_(srcDC) 
    BMPHandle = CreateCompatibleBitmap_(srcDC, Width2, Height2) 
    SelectObject_( trgDC, BMPHandle) 
    BitBlt_( trgDC, 0, 0, Width2, Height2, srcDC, Left2, Top2, #SRCCOPY) 
    DeleteDC_( trgDC) 
    ReleaseDC_( BMPHandle, srcDC) 
    ProcedureReturn BMPHandle 
EndProcedure 



OpenLibrary(0,"winmm.dll") 
width.l=512 ;width of window 
height.l=384 ;and the height 
mType.s="AviVideo" 
statusBuf.s="" 
filename.s="Shrek.avi" ;the avi file name goes here 
command.s="" 

OpenWindow(0,0,0,width,height,#PB_Window_ScreenCentered,"",0) 

CreateGadgetList(WindowID(0)) 
TextGadget(1,0,0,width,height,"ljl") 


command="open "+Chr(34)+filename+Chr(34)+" type "+mType+" alias sfx" 
CallFunction(0,"mciSendStringA",command,"",0,0) 


hw1=GadgetID(1) 
command = "window sfx handle " + Str(hw1) 
CallFunction(0,"mciSendStringA",command,"",0,0) 
CallFunction(0,"mciSendStringA","put sfx destination at 0 0 "+Str(width)+" "+Str(height),"",0,0) 




CallFunction(0,"mciSendStringA","set sfx time format frames" ,"",0,0) 
CallFunction(0,"mciSendStringA","info sfx file wait",statusBuf,254,0) 
CallFunction(0,"mciSendStringA","status sfx length",statusBuf,254,0) 
playLength=Val(statusBuf) 



For r=0 To 1050 
Delay(1) 
WindowEvent() 
CallFunction(0,"mciSendStringA","play sfx from "+Str(r)+" To "+Str(r),"",0,0) 
If r=>200
  Left=0
  Top=0
  Width = GetSystemMetrics_(#SM_CXSCREEN) 
  Height = GetSystemMetrics_(#SM_CYSCREEN) 
  DeskTopSprite = 1
  *DeskTop = CaptureDesktop(Left, Top, Width, Height)

CreateImage(DeskTop, Width, Height)
CreateImage(DeskTopSprite,Width, Height)
  StartDrawing(ImageOutput()) 
  DrawImage(*DeskTop, 1, 1) 
  StopDrawing()
SaveImage(DeskTopSprite, "Test.bmp" ,#PB_ImagePlugin_BMP ) 

End
EndIf
Next r 


CallFunction(0,"mciSendStringA","close all","",0,0)


hope it helps
Sean
TIGER
User
User
Posts: 81
Joined: Mon Feb 23, 2004 8:33 pm

Post by TIGER »

Thanks . It better than nothing i guess.
Let see if i can capture jus a part of it.
Or fullscreen maybe. :?
PIII450 128RAM TNT2
User avatar
J. Baker
Addict
Addict
Posts: 2192
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
TIGER
User
User
Posts: 81
Joined: Mon Feb 23, 2004 8:33 pm

Post by TIGER »

Thanks ill try it.
PIII450 128RAM TNT2
Post Reply