News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Recording AVI Example

Started by kevin, January 25, 2010, 05:30:38 PM

Previous topic - Next topic

kevin

 Recording AVI Example

 This example uses the PB_AVI library (login required) to save a 10 second stream of video.    


 

PlayBASIC Code: [Select]
   ; include the PV _AVI library..   
#include "PB_AVI"


; Size of Screen
Width =800
Height =600


; set up PB screen mode and frame rate
SetFps 30
openscreen Width,Height,32,1
ScreenVsync true

; create FX surface, so we can capture from it
Screen=NewFXImage(Width,Height)



; output file name of AVI file, This will be pretty large
AVIFilename$="C:\Video.avi"


; ---------------------------------------------------------------------------
; ----------------------->> Main Loop <<-----------------------------
; ---------------------------------------------------------------------------


Do

// Draw the demo scene/effect..
Draw_Demo(Screen)



// if not capturing, draw the normal screen, so we can see it
if MyAvi=0

DrawIMage Screen,0,0,false
else

Cls 255
// when capturing draw the AVI screen, so we can see it
DrawAVI MyAvi,0,0,false
endif


// Check if the F5 is pressed, if it is start writing an AVI file
if FunctionKeys(5)=true and MyAvi=0

; disable user break
breakkey off

; open an AVI stream.
MyAVI=WriteAvi(AVIFilename$,1000/GetFps(),Width/2,Height/2)

// set record time for 10 seconds
MAxRecordTime=Timer()+(10000)

endif


// if we've an open AVI, drop the current frame to it
if MyAvi
AddFrameToAvi(myAVI,Screen)
text 0,0,"Recording:"+AVIFilename$
endif


// Check if the time limit has been exceeded, if so, Close the AVI
if Timer()>MaxRecordTime
CloseAvi(MyAvi)
MyAvi=0

breakkey on
endif


; refressh the display, and loop back to the do statement
Sync
loop





; ---------------------------------------------------------------------------
; ----------------------->> Draw Demo (Scene <<-----------------------------
; ---------------------------------------------------------------------------
;
; This function just draws a simple scene so we've something to look at/and
; capture.
;
; ---------------------------------------------------------------------------



Function Draw_Demo(Screen)

RenderToIMage Screen

width=getimagewidth(Screen)
height=getimageheight(Screen)

static Init_points,x1#,y1#,x2#,y2#
if Init_points=0
x1#=Rnd(width)
y1#=Rnd(Height)
x2#=Rnd(width)
y2#=Rnd(Height)
Init_points=true
endif

inkmode 1+2048
boxc 0,0,width,height,true,$00fff0ff

x1#=curvevalue(x2#,x1#,10)
y1#=curvevalue(y2#,y1#,10)

inkmode 1+64
circle x1#,y1#,50,true
inkmode 1


dist#=GetDistance2d(X1#,y1#,x2#,y2#)
if Dist#<2
x2#=Rnd(width)
y2#=Rnd(Height)
endif

RenderToScreen

endFunction





ATLUS


Big C.

If I try the example I don't get a avi file under win7. I think c:\ is destricted so i help me with command TempDir$(). Is there another way how I can identify a Folder/Path with user rights under win7 ?

Adaz

Quote from: Big C. on January 26, 2010, 03:26:25 PM
If I try the example I don't get a avi file under win7. I think c:\ is destricted so i help me with command TempDir$(). Is there another way how I can identify a Folder/Path with user rights under win7 ?
Try to create a file there, then check if it exists or not. Of couse you have to check its existence before the creation too.

Ádáz

Hungary

ATLUS

but how can you put value Deputy ThisSourceImage screen?
AddFrameToAVI(index,ThisSourceImage)