(Eine Exe pro Cam drei mal ausgeführt)
Wie sieht überhaupt Dein Quellcode aus ?
Wo ist denn gerade der Winter hin ?
Fragen über Fragen

Grüsse Joshy
Code: Alles auswählen
; -----------------------------------------------------------------------------
; ORIGINAL VB TEXT...
; -----------------------------------------------------------------------------
;* Author: E. J. Bantz Jr.
;* Copyright: None, use and distribute freely ...
;* E-Mail: ejbantz@usa.net
;* Web: http://www.inlink.com/~ejbantz just http://ej.bantz.com/video/
; [ Ported to PureBasic by James @ hi-toro.com ]
; -----------------------------------------------------------------------------
; Some extra PB procedures...
; -----------------------------------------------------------------------------
; Show fatal error message, end program...
; Converted and extended to PB4.31 from Falko (German Forum)
; Change all Constants with (), Just Stop and Abort is running for PB 4.4
; www.falko-pure.de
Procedure FatalError (error$)
If error$ = "": error$ = "Undefined error... outta here!": EndIf
MessageRequester ("Program error -- aborting...", error$, #MB_ICONWARNING | #MB_SYSTEMMODAL)
End
EndProcedure
; Open avicap32.dll as PB library number 0...
Procedure OpenAviLibrary ()
If OpenLibrary (0, "avicap32.dll") = 0
FatalError ("Can't open avicap32.dll!")
EndIf
EndProcedure
; Close avicap32.dll -- crashes...!
Procedure CloseAviLibrary ()
; CloseLibrary (0) ; Close avicap32.dll -- causes crash/freeze!
EndProcedure
; Function undefined in PB -- uses avicap32.dll to create capture window (returns handle)...
Procedure.l capCreateCaptureWindowA(lpszWindowName, dwStyle.l, x.l, y.l, nWidth.l, nHeight.b, hWndParent.l, nID.l)
ProcedureReturn CallFunction (0,"capCreateCaptureWindowA", lpszWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, nID)
EndProcedure
; Function undefined in PB -- uses avicap32.dll to get [default?] capture device name. Places
; name and version strings into memory pointers defined when calling...
Procedure.b capGetDriverDescriptionA (wDriver.b, *lpszName, cbName.l, *lpszVer, cbVer.l)
CallFunction (0, "capGetDriverDescriptionA", wDriver, *lpszName, cbName, *lpszVer, cbVer)
EndProcedure
;// ------------------------------------------------------------------
;// Windows API Constants / Types / Declarations
;// ------------------------------------------------------------------
#WM_USER = $400
#WS_CHILD = $40000000
#WS_VISIBLE = $10000000
#SWP_NOMOVE = $2
#SWP_NOZORDER = $4
#HWND_BOTTOM = 1
Global lNFrames.l
;// ------------------------------------------------------------------
;// Window Messages WM_CAP... which can be sent to an AVICAP window
;// ------------------------------------------------------------------
;// Defines start of the message range
#WM_CAP_START = #WM_USER
#WM_CAP_GET_CAPSTREAMPTR = (#WM_CAP_START + 1)
#WM_CAP_SET_CALLBACK_ERROR = (#WM_CAP_START + 2)
#WM_CAP_SET_CALLBACK_STATUS = (#WM_CAP_START + 3)
#WM_CAP_SET_CALLBACK_YIELD = (#WM_CAP_START + 4)
#WM_CAP_SET_CALLBACK_FRAME = (#WM_CAP_START + 5)
#WM_CAP_SET_CALLBACK_VIDEOSTREAM = (#WM_CAP_START + 6)
#WM_CAP_SET_CALLBACK_WAVESTREAM = (#WM_CAP_START + 7)
#WM_CAP_GET_USER_DATA = (#WM_CAP_START + 8)
#WM_CAP_SET_USER_DATA = (#WM_CAP_START + 9)
#WM_CAP_DRIVER_CONNECT = (#WM_CAP_START + 10)
#WM_CAP_DRIVER_DISCONNECT = (#WM_CAP_START + 11)
#WM_CAP_DRIVER_GET_NAME = (#WM_CAP_START + 12)
#WM_CAP_DRIVER_GET_VERSION = (#WM_CAP_START + 13)
#WM_CAP_DRIVER_GET_CAPS = (#WM_CAP_START + 14)
#WM_CAP_FILE_SET_CAPTURE_FILE = (#WM_CAP_START + 20)
#WM_CAP_FILE_GET_CAPTURE_FILE = (#WM_CAP_START + 21)
#WM_CAP_FILE_ALLOCATE = (#WM_CAP_START + 22)
#WM_CAP_FILE_SAVEAS = (#WM_CAP_START + 23)
#WM_CAP_FILE_SET_INFOCHUNK = #WM_CAP_START + 24
#WM_CAP_FILE_SAVEDIB = (#WM_CAP_START + 25)
#WM_CAP_EDIT_COPY = (#WM_CAP_START + 30)
#WM_CAP_SET_AUDIOFORMAT = (#WM_CAP_START + 35)
#WM_CAP_GET_AUDIOFORMAT = (#WM_CAP_START + 36)
#WM_CAP_DLG_VIDEOFORMAT = (#WM_CAP_START + 41)
#WM_CAP_DLG_VIDEOSOURCE = (#WM_CAP_START + 42)
#WM_CAP_DLG_VIDEODISPLAY = (#WM_CAP_START + 43)
#WM_CAP_GET_VIDEOFORMAT = (#WM_CAP_START + 44)
#WM_CAP_SET_VIDEOFORMAT = (#WM_CAP_START + 45)
#WM_CAP_DLG_VIDEOCOMPRESSION = (#WM_CAP_START + 46)
#WM_CAP_SET_PREVIEW = (#WM_CAP_START + 50)
#WM_CAP_SET_OVERLAY = (#WM_CAP_START + 51)
#WM_CAP_SET_PREVIEWRATE = (#WM_CAP_START + 52)
#WM_CAP_SET_SCALE = (#WM_CAP_START + 53)
#WM_CAP_GET_STATUS = (#WM_CAP_START + 54)
#WM_CAP_SET_SCROLL = (#WM_CAP_START + 55)
#WM_CAP_GRAB_FRAME = (#WM_CAP_START + 60)
#WM_CAP_GRAB_FRAME_NOSTOP = (#WM_CAP_START + 61)
#WM_CAP_SEQUENCE = (#WM_CAP_START + 62)
#WM_CAP_SEQUENCE_NOFILE = (#WM_CAP_START + 63)
#WM_CAP_SET_SEQUENCE_SETUP = (#WM_CAP_START + 64)
#WM_CAP_GET_SEQUENCE_SETUP = (#WM_CAP_START + 65)
#WM_CAP_SET_MCI_DEVICE = (#WM_CAP_START + 66)
#WM_CAP_GET_MCI_DEVICE = (#WM_CAP_START + 67)
#WM_CAP_STOP = (#WM_CAP_START + 68)
#WM_CAP_ABORT = (#WM_CAP_START + 69)
#WM_CAP_SINGLE_FRAME_OPEN = (#WM_CAP_START + 70)
#WM_CAP_SINGLE_FRAME_CLOSE = (#WM_CAP_START + 71)
#WM_CAP_SINGLE_FRAME = (#WM_CAP_START + 72)
#WM_CAP_PAL_OPEN = (#WM_CAP_START + 80)
#WM_CAP_PAL_SAVE = (#WM_CAP_START + 81)
#WM_CAP_PAL_PASTE = (#WM_CAP_START + 82)
#WM_CAP_PAL_AUTOCREATE = (#WM_CAP_START + 83)
#WM_CAP_PAL_MANUALCREATE = (#WM_CAP_START + 84)
;// Following added post VFW 1.1
#WM_CAP_SET_CALLBACK_CAPCONTROL = (#WM_CAP_START + 85)
;// Defines end of the message range
;#WM_CAP_END = #WM_CAP_SET_CALLBACK_CAPCONTROL
;// ------------------------------------------------------------------
;// Structures
;// ------------------------------------------------------------------
Structure CAPDRIVERCAPS
wDeviceIndex.l ; // Driver index in system.ini
fHasOverlay.l ; // Can device overlay?
fHasDlgVideoSource.l ; // Has Video source dlg?
fHasDlgVideoFormat.l ; // Has Format dlg?
fHasDlgVideoDisplay.l ; // Has External out dlg?
fCaptureInitialized.l ; // Driver ready to capture?
fDriverSuppliesPalettes.l ; // Can driver make palettes?
hVideoIn.l ; // Driver In channel
hVideoOut.l ; // Driver Out channel
hVideoExtIn.l ; // Driver Ext In channel
hVideoExtOut.l ; // Driver Ext Out channel
EndStructure
Structure CAPSTATUS
uiImageWidth.l ;// Width of the image
uiImageHeight.l ;// Height of the image
fLiveWindow.l ;// Now Previewing video?
fOverlayWindow.l ;// Now Overlaying video?
fScale.l ;// Scale image to client?
ptScroll.POINT ;// Scroll position
fUsingDefaultPalette.l ;// Using default driver palette?
fAudioHardware.l ;// Audio hardware present?
fCapFileExists.l ;// Does capture file exist?
dwCurrentVideoFrame.l ;// # of video frames cap;td
dwCurrentVideoFramesDropped.l ;// # of video frames dropped
dwCurrentWaveSamples.l ;// # of wave samples cap;td
dwCurrentTimeElapsedMS.l ;// Elapsed capture duration
hPalCurrent.l ;// Current palette in use
fCapturingNow.l ;// Capture in progress?
dwReturn.l ;// Error value after any operation
wNumVideoAllocated.l ;// Actual number of video buffers
wNumAudioAllocated.l ;// Actual number of audio buffers
EndStructure
Structure CAPTUREPARMS
dwRequestMicroSecPerFrame.l ;// Requested capture rate
fMakeUserHitOKToCapture.l ;// Show "Hit OK to cap" dlg?
wPercentDropForError.l ;// Give error msg if > (10%)
fYield.l ;// Capture via background task?
dwIndexSize.l ;// Max index size in frames (32K)
wChunkGranularity.l ;// Junk chunk granularity (2K)
fUsingDOSMemory.l ;// Use DOS buffers?
wNumVideoRequested.l ;// # video buffers, If 0, autocalc
fCaptureAudio.l ;// Capture audio?
wNumAudioRequested.l ;// # audio buffers, If 0, autocalc
vKeyAbort.l ;// Virtual key causing abort
fAbortLeftMouse.l ;// Abort on left mouse?
fAbortRightMouse.l ;// Abort on right mouse?
fLimitEnabled.l ;// Use wTimeLimit?
wTimeLimit.l ;// Seconds to capture
fMCIControl.l ;// Use MCI video source?
fStepMCIDevice.l ;// Step MCI device?
dwMCIStartTime.l ;// Time to start in MS
dwMCIStopTime.l ;// Time to stop in MS
fStepCaptureAt2x.l ;// Perform spatial averaging 2x
wStepCaptureAverageFrames.l ;// Temporal average n Frames
dwAudioBufferSize.l ;// Size of audio bufs (0 = default)
fDisableWriteCache.l ;// Attempt to disable write cache
EndStructure
Structure CAPINFOCHUNK
fccInfoID.l ;// Chunk ID, "ICOP" for copyright
lpData.l ;// pointer to data
cbData.l ;// size of lpData
EndStructure
Structure VIDEOHDR
lpData.l ;// address of video buffer
dwBufferLength.l ;// size, in bytes, of the Data buffer
dwBytesUsed.l ;// see below
dwTimeCaptured.l ;// see below
dwUser.l ;// user-specific data
dwFlags.l ;// see below
dwReserved.l[3] ;// reserved; do not use}
EndStructure
;// ------------------------------------------------------------------
;// String IDs from status and error callbacks
;// ------------------------------------------------------------------
#IDS_CAP_BEGIN = 300 ;/* "Capture Start" */
#IDS_CAP_END = 301 ;/* "Capture End" */
#IDS_CAP_INFO = 401 ;/* "%s" */
#IDS_CAP_OUTOFMEM = 402 ;/* "Out of memory" */
#IDS_CAP_FILEEXISTS = 403 ;/* "File ;%s; exists -- overwrite it?" */
#IDS_CAP_ERRORPALOPEN = 404 ;/* "Error opening palette ;%s;" */
#IDS_CAP_ERRORPALSAVE = 405 ;/* "Error saving palette ;%s;" */
#IDS_CAP_ERRORDIBSAVE = 406 ;/* "Error saving frame ;%s;" */
#IDS_CAP_DEFAVIEXT = 407 ;/* "avi" */
#IDS_CAP_DEFPALEXT = 408 ;/* "pal" */
#IDS_CAP_CANTOPEN = 409 ;/* "Cannot open ;%s;" */
#IDS_CAP_SEQ_MSGSTART = 410 ;/* "Select OK to start capture\nof video sequence\nto %s." */
#IDS_CAP_SEQ_MSGSTOP = 411 ;/* "Hit ESCAPE or click to end capture" */
#IDS_CAP_VIDEDITERR = 412 ;/* "An error occurred while trying to run VidEdit." */
#IDS_CAP_READONLYFILE = 413 ;/* "The file ;%s; is a read-only file." */
#IDS_CAP_WRITEERROR = 414 ;/* "Unable to write to file ;%s;.\nDisk may be full." */
#IDS_CAP_NODISKSPACE = 415 ;/* "There is no space to create a capture file on the specified device." */
#IDS_CAP_SETFILESIZE = 416 ;/* "Set File Size" */
#IDS_CAP_SAVEASPERCENT = 417 ;/* "SaveAs: %2ld%% Hit Escape to abort." */
#IDS_CAP_DRIVER_ERROR = 418 ;/* Driver specific error message */
#IDS_CAP_WAVE_OPEN_ERROR = 419 ;/* "Error: Cannot open the wave input device.\nCheck sample size, frequency, and channels." */
#IDS_CAP_WAVE_ALLOC_ERROR = 420 ;/* "Error: Out of memory for wave buffers." */
#IDS_CAP_WAVE_PREPARE_ERROR = 421 ;/* "Error: Cannot prepare wave buffers." */
#IDS_CAP_WAVE_ADD_ERROR = 422 ;/* "Error: Cannot add wave buffers." */
#IDS_CAP_WAVE_SIZE_ERROR = 423 ;/* "Error: Bad wave size." */
#IDS_CAP_VIDEO_OPEN_ERROR = 424 ;/* "Error: Cannot open the video input device." */
#IDS_CAP_VIDEO_ALLOC_ERROR = 425 ;/* "Error: Out of memory for video buffers." */
#IDS_CAP_VIDEO_PREPARE_ERROR = 426 ;/* "Error: Cannot prepare video buffers." */
#IDS_CAP_VIDEO_ADD_ERROR = 427 ;/* "Error: Cannot add video buffers." */
#IDS_CAP_VIDEO_SIZE_ERROR = 428 ;/* "Error: Bad video size." */
#IDS_CAP_FILE_OPEN_ERROR = 429 ;/* "Error: Cannot open capture file." */
#IDS_CAP_FILE_WRITE_ERROR = 430 ;/* "Error: Cannot write to capture file. Disk may be full." */
#IDS_CAP_RECORDING_ERROR = 431 ;/* "Error: Cannot write to capture file. Data rate too high or disk full." */
#IDS_CAP_RECORDING_ERROR2 = 432 ;/* "Error while recording" */
#IDS_CAP_AVI_INIT_ERROR = 433 ;/* "Error: Unable to initialize for capture." */
#IDS_CAP_NO_FRAME_CAP_ERROR = 434 ;/* "Warning: No frames captured.\nConfirm that vertical sync interrupts\nare configured and enabled." */
#IDS_CAP_NO_PALETTE_WARN = 435 ;/* "Warning: Using default palette." */
#IDS_CAP_MCI_CONTROL_ERROR = 436 ;/* "Error: Unable to access MCI device." */
#IDS_CAP_MCI_CANT_STEP_ERROR = 437 ;/* "Error: Unable to step MCI device." */
#IDS_CAP_NO_AUDIO_CAP_ERROR = 438 ;/* "Error: No audio data captured.\nCheck audio card settings." */
#IDS_CAP_AVI_DRAWDIB_ERROR = 439 ;/* "Error: Unable to draw this data format." */
#IDS_CAP_COMPRESSOR_ERROR = 440 ;/* "Error: Unable to initialize compressor." */
#IDS_CAP_AUDIO_DROP_ERROR = 441 ;/* "Error: Audio data was lost during capture, reduce capture rate." */
;/* status string IDs */
#IDS_CAP_STAT_LIVE_MODE = 500 ;/* "Live window" */
#IDS_CAP_STAT_OVERLAY_MODE = 501 ;/* "Overlay window" */
#IDS_CAP_STAT_CAP_INIT = 502 ;/* "Setting up for capture - Please wait" */
#IDS_CAP_STAT_CAP_FINI = 503 ;/* "Finished capture, now writing frame %ld" */
#IDS_CAP_STAT_PALETTE_BUILD = 504 ;/* "Building palette map" */
#IDS_CAP_STAT_OPTPAL_BUILD = 505 ;/* "Computing optimal palette" */
#IDS_CAP_STAT_I_FRAMES = 506 ;/* "%d frames" */
#IDS_CAP_STAT_L_FRAMES = 507 ;/* "%ld frames" */
#IDS_CAP_STAT_CAP_L_FRAMES = 508 ;/* "Captured %ld frames" */
#IDS_CAP_STAT_CAP_AUDIO = 509 ;/* "Capturing audio" */
#IDS_CAP_STAT_VIDEOCURRENT = 510 ;/* "Captured %ld frames (%ld dropped) %d.%03d sec." */
#IDS_CAP_STAT_VIDEOAUDIO = 511 ;/* "Captured %d.%03d sec. %ld frames (%ld dropped) (%d.%03d fps). %ld audio bytes (%d,%03d sps)" */
#IDS_CAP_STAT_VIDEOONLY = 512 ;/* "Captured %d.%03d sec. %ld frames (%ld dropped) (%d.%03d fps)" */
Procedure capSetCallbackOnError (lwnd.l, lpProc.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_ERROR, 0, lpProc)
EndProcedure
Procedure capSetCallbackOnStatus (lwnd.l, lpProc.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_STATUS, 0, lpProc)
EndProcedure
Procedure capSetCallbackOnYield (lwnd.l, lpProc.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_YIELD, 0, lpProc)
EndProcedure
Procedure capSetCallbackOnFrame (lwnd.l, lpProc.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_FRAME, 0, lpProc)
EndProcedure
Procedure capSetCallbackOnVideoStream (lwnd.l, lpProc.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, lpProc)
EndProcedure
Procedure capSetCallbackOnWaveStream (lwnd.l, lpProc.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_WAVESTREAM, 0, lpProc)
EndProcedure
Procedure capSetCallbackOnCapControl (lwnd.l, lpProc.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_CALLBACK_CAPCONTROL, 0, lpProc)
EndProcedure
Procedure capSetUserData (lwnd.l, lUser.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_USER_DATA, 0, lUser)
EndProcedure
Procedure capGetUserData (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GET_USER_DATA, 0, 0)
EndProcedure
Procedure capDriverConnect (lwnd.l, i.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_DRIVER_CONNECT, i, 0)
EndProcedure
Procedure capDriverDisconnect (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_DRIVER_DISCONNECT, 0, 0)
EndProcedure
Procedure capDriverGetName (lwnd.l, szName.s, wSize.b)
ProcedureReturn SendMessage_ (lwnd, YOURCONSTANTMESSAGE, wSize, szName)
EndProcedure
Procedure capDriverGetVersion (lwnd.l, szVer.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_DRIVER_GET_VERSION, wSize, szVer)
EndProcedure
Procedure capDriverGetCaps (lwnd.l, s.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_DRIVER_GET_CAPS, wSize, s)
EndProcedure
Procedure capFileSetCaptureFile (lwnd.l, szName.s)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_FILE_SET_CAPTURE_FILE, 0, szName)
EndProcedure
Procedure capFileGetCaptureFile (lwnd.l, szName.s, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_FILE_SET_CAPTURE_FILE, wSize, szName)
EndProcedure
Procedure capFileAlloc (lwnd.l, dwSize.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_FILE_ALLOCATE, 0, dwSize)
EndProcedure
Procedure capFileSaveAs (lwnd.l, szName.s)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_FILE_SAVEAS, 0, szName)
EndProcedure
Procedure capFileSetInfoChunk (lwnd.l, lpInfoChunk.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_FILE_SET_INFOCHUNK, 0, lpInfoChunk)
EndProcedure
Procedure capFileSaveDIB (lwnd.l, szName.s)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_FILE_SAVEDIB, 0, szName)
EndProcedure
Procedure capEditCopy (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_EDIT_COPY, 0, 0)
EndProcedure
Procedure capSetAudioFormat (lwnd.l, s.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_AUDIOFORMAT, wSize, s)
EndProcedure
Procedure capGetAudioFormat (lwnd.l, s.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GET_AUDIOFORMAT, wSize, s)
EndProcedure
Procedure capGetAudioFormatSize (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GET_AUDIOFORMAT, 0, 0)
EndProcedure
Procedure capDlgVideoFormat (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_DLG_VIDEOFORMAT, 0, 0)
EndProcedure
Procedure capDlgVideoSource (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_DLG_VIDEOSOURCE, 0, 0)
EndProcedure
Procedure capDlgVideoDisplay (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_DLG_VIDEODISPLAY, 0, 0)
EndProcedure
Procedure capDlgVideoCompression (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0)
EndProcedure
Procedure capGetVideoFormat (lwnd.l, s.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GET_VIDEOFORMAT, wSize, s)
EndProcedure
Procedure capGetVideoFormatSize (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GET_VIDEOFORMAT, 0, 0)
EndProcedure
Procedure capSetVideoFormat (lwnd.l, s.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_VIDEOFORMAT, wSize, s)
EndProcedure
Procedure capPreview (lwnd.l, f.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_PREVIEW, f, 0)
EndProcedure
Procedure capPreviewRate (lwnd.l, wMS.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_PREVIEWRATE, wMS, 0)
EndProcedure
Procedure capOverlay (lwnd.l, f.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_OVERLAY, f, 0)
EndProcedure
Procedure capPreviewScale (lwnd.l, f.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_SCALE, f, 0)
EndProcedure
Procedure capGetStatus (lwnd.l, s.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GET_STATUS, wSize, s)
EndProcedure
Procedure capSetScrollPos (lwnd.l, lpP.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_SCROLL, 0, lpP)
EndProcedure
Procedure capGrabFrame (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GRAB_FRAME, 0, 0)
EndProcedure
Procedure capGrabFrameNoStop (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GRAB_FRAME_NOSTOP, 0, 0)
EndProcedure
Procedure capCaptureSequence (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SEQUENCE, 0, 0)
EndProcedure
Procedure capCaptureSequenceNoFile (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SEQUENCE_NOFILE, 0, 0)
EndProcedure
Procedure capCaptureStop (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_STOP, 0, 0)
EndProcedure
Procedure capCaptureAbort (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_ABORT, 0, 0)
EndProcedure
Procedure capCaptureSingleFrameOpen (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SINGLE_FRAME_OPEN, 0, 0)
EndProcedure
Procedure capCaptureSingleFrameClose (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SINGLE_FRAME_CLOSE, 0, 0)
EndProcedure
Procedure capCaptureSingleFrame (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SINGLE_FRAME, 0, 0)
EndProcedure
Procedure capCaptureGetSetup (lwnd.l, s.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GET_SEQUENCE_SETUP, wSize, s)
EndProcedure
Procedure capCaptureSetSetup (lwnd.l, s.l, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_SEQUENCE_SETUP, wSize, s)
EndProcedure
Procedure capSetMCIDeviceName (lwnd.l, szName.s)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_SET_MCI_DEVICE, 0, szName)
EndProcedure
Procedure capGetMCIDeviceName (lwnd.l, szName.s, wSize.b)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_GET_MCI_DEVICE, wSize, szName)
EndProcedure
Procedure capPaletteOpen (lwnd.l, szName.s)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_PAL_OPEN, 0, szName)
EndProcedure
Procedure capPaletteSave (lwnd.l, szName.s)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_PAL_SAVE, 0, szName)
EndProcedure
Procedure capPalettePaste (lwnd.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_PAL_PASTE, 0, 0)
EndProcedure
Procedure capPaletteAuto (lwnd.l, iFrames.b, iColor.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_PAL_AUTOCREATE, iFrames, iColors)
EndProcedure
Procedure capPaletteManual (lwnd.l, fGrab.b, iColors.l)
ProcedureReturn SendMessage_ (lwnd, #WM_CAP_PAL_MANUALCREATE, fGrab, iColors)
EndProcedure
Procedure MyFrameCallback (lwnd.l, lpVHdr.l)
Define.VIDEOHDR VideoHeader
;//Fill VideoHeader with data at lpVHdr
RtlMoveMemory_ (@VideoHeader, lpVHdr, SizeOf (VIDEOHDR))
;// Make room for data
Dim VideoData (VideoHeader\dwBytesUsed)
;//Copy data into the array
ProcedureReturn RtlMoveMemory_ (@VideoData (0), VideoHeader\lpData, VideoHeader\dwBytesUsed)
EndProcedure
Procedure MyYieldCallback (lwnd.l)
Debug "Yield"
ProcedureReturn
EndProcedure
Procedure MyErrorCallback (lwnd.l, iID.l, ipstrStatusText.l)
If iID = 0
ProcedureReturn 0
EndIf
; define.s sStatusText
; define.s usStatusText
;Convert the Pointer to a real VB String
; sStatusText = Space$ (255) ;// Make room for message
;lStrCpy StrPtr (sStatusText), ipstrStatusText ;// Copy message into String
; PokeS (@sStatusText, PeekS (ipstrStatusText))
; sStatusText = Left (sStatusText, InStr (sStatusText, Chr$ (0)) - 1) ;// Only look at left of null
; ^^^ Not needed? PB should sort that, I think...
; usStatusText = StrConv (sStatusText, vbUnicode) ;// Convert Unicode
;Debug.Print "Error: ", usStatusText, iID
EndProcedure
Procedure MyStatusCallback (lwnd.l, iID.l, ipstrStatusText.l)
If iID = 0
ProcedureReturn 0
EndIf
sStatusText.s
usStatusText.s
;// Convert the Pointer to a real VB String
sStatusText = PeekS(255, 0) ;Make room for message
PokeS(ipstrStatusText,sStatusText) ;// Copy message into String
sStatusText = Left(sStatusText, FindString(sStatusText, Chr(0),0) - 1) ;// Only look at left of null
usStatusText = PeekS(*sStatusText, #PB_Unicode) ;// Convert Unicode
Debug "Status: " + PeekS(@usStatusText,iID)
EndProcedure
Procedure MyVideoStreamCallback (lwnd.l, lpVHdr.l)
;Beep ;// Replace this with your code!
EndProcedure
Procedure.l MyWaveStreamCallback (lwnd.l, lpVHdr.l)
; Debug.Print "WaveStream"
EndProcedure
Global gPreviewStatus: gPreviewStatus = #True ; Status of 'Preview' option...
Global lwndC.l ; ' Handle to the Capture Windows
Global lNFrames.l ; ' Number of frames captured
Global dlgSource.l: dlgSource = #True
Global dlgFormat.l: dlgFormat = #True
Global dlgDisplay.l: dlgDisplay = #True
Global capWidth, capHeight
Procedure ResizeCaptureWindow (lwnd.l)
Define.CAPSTATUS capstat
;// Get the capture window attributes .. width and height
capGetStatus (lwnd, @capstat, SizeOf (CAPSTATUS))
;// Resize the capture window to the capture sizes
SetWindowPos_ (lwnd, #HWND_BOTTOM, 0, 0, capstat\uiImageWidth, capstat\uiImageHeight, #SWP_NOMOVE | #SWP_NOZORDER)
capWidth = capstat\uiImageWidth
capHeight = capstat\uiImageHeight
EndProcedure
Procedure StartCaptureWindow (parentwindow.l)
lpszName = AllocateMemory (100)
lpszVer = AllocateMemory (100)
Define.CAPDRIVERCAPS Caps
;//Create Capture Window
capGetDriverDescriptionA (0, lpszName, 100, lpszVer, 100) ;// Retrieves driver info
name$ = PeekS (lpszName)
lwndC = capCreateCaptureWindowA (name, #WS_CHILD | #WS_VISIBLE, 0, 0, 320, 240, parentwindow, 1)
;// Connect the capture window to the driver
capDriverConnect (lwndC, 0)
;// Get the capabilities of the capture driver
capDriverGetCaps (lwndC, @Caps, SizeOf (CAPDRIVERCAPS))
;// If the capture driver does not support a dialog, grey it out
;// in the menu bar.
If Caps\fHasDlgVideoSource = 0
dlgSource = #False
EndIf
If Caps\fHasDlgVideoFormat = 0
dlgFormat = #False
EndIf
If Caps\fHasDlgVideoDisplay = 0
dlgDisplay = #False
EndIf
;// Set the video stream callback function
capSetCallbackOnVideoStream (lwndC, @MyVideoStreamCallback ())
capSetCallbackOnFrame (lwndC, @MyFrameCallback ())
;// Set the preview rate in milliseconds
capPreviewRate (lwndC, 1)
;// Set Overlay
capOverlay (lwndC, #True)
;// Start previewing the image from the camera
capPreview (lwndC, #True)
;// Resize the capture window to show the whole image
ResizeCaptureWindow (lwndC)
EndProcedure
Procedure EndCaptureWindow (Cancel.b)
;// Disable all callbacks
capSetCallbackOnError (lwndC, #Null)
capSetCallbackOnStatus (lwndC, #Null)
capSetCallbackOnYield (lwndC, #Null)
capSetCallbackOnFrame (lwndC, #Null)
capSetCallbackOnVideoStream (lwndC, #Null)
capSetCallbackOnWaveStream (lwndC, #Null)
capSetCallbackOnCapControl (lwndC, #Null)
EndProcedure
Procedure GetAudioFormat_Click(); by Falko
Protected Outtxt.s
Define.WAVEFORMATEX s
capGetAudioFormat (lwndC, @s, SizeOf(WAVEFORMATEX))
Outtxt.s = "FormatTag : "+Str(s\wFormatTag)+#CRLF$
Outtxt + "Channels : "+Str(s\nChannels)+#CRLF$
Outtxt + "SamplesPerSec : "+Str(s\nSamplesPerSec)+#CRLF$
Outtxt + "AvgBytesPerSec: "+Str(s\nAvgBytesPerSec)+#CRLF$
Outtxt + "BlockAlign : "+Str(s\nBlockAlign)+#CRLF$
Outtxt + "BitsPerSample : "+Str(s\wBitsPerSample)
MessageRequester("AudioFormat",Outtxt)
EndProcedure
Procedure Compression_Click ()
capDlgVideoCompression (lwndC)
EndProcedure
Procedure Display_Click ()
capDlgVideoDisplay (lwndC)
EndProcedure
Procedure Format_Click ()
capDlgVideoFormat (lwndC)
ResizeCaptureWindow (lwndC)
EndProcedure
Procedure.l Preview_Click ()
If gPreviewStatus
gPreviewStatus = #False
Else
gPreviewStatus = #True
EndIf
capPreview (lwndC, gPreviewStatus)
ProcedureReturn gPreviewStatus
EndProcedure
Procedure Source_Click ()
capDlgVideoSource (lwndC)
EndProcedure
Procedure Start_Click ()
; /*
; * If Start is selected from the menu, start Streaming capture.
; * The streaming capture is terminated when the Escape key is pressed
; */
CAP_PARAMS.CAPTUREPARMS
sFileName.s="TestAVI.avi"
If capCaptureGetSetup(lwndC,@CAP_PARAMS,SizeOf(CAP_PARAMS))
CAP_PARAMS\fYield=#True
CAP_PARAMS\dwRequestMicroSecPerFrame=(1*(Pow(10,6))/30); 30 Frames per second
CAP_PARAMS\fMakeUserHitOKToCapture = #True
CAP_PARAMS\fCaptureAudio = #True ;Ich höre nur rauschen, aber es kann sein, das ich TV und Soundkarte verbinden muss !
CAP_PARAMS\vKeyAbort=#False ;// Virtual key causing abort
CAP_PARAMS\fAbortLeftMouse=#False ;// Abort on left mouse?
CAP_PARAMS\fAbortRightMouse=#False ;// Abort on right mouse?
CAP_PARAMS\fLimitEnabled=#False ;// Use wTimeLimit?
CAP_PARAMS\wTimeLimit=#False ;// Seconds to capture
capCaptureSetSetup (lwndC, @CAP_PARAMS, SizeOf(CAP_PARAMS))
capFileSetCaptureFile (lwndC,"Test.AVI");Write Filename for AVI
capCaptureSequence(lwndC) ; Start Capturing!
EndIf
EndProcedure
Procedure SnapShot(); Make a Snapshot from Life-Video
Name.s=ReplaceString(FormatDate("%yy-%mm-%dd @ %hh#%ii#%ss", Date()) + ".bmp","#",Chr(149))
SendMessage_(lwndC, #WM_CAP_FILE_SAVEDIB, 0,Name)
EndProcedure
Code: Alles auswählen
IncludeFile "avicapincs.pbi"
; -----------------------------------------------------------------------------
; D E M O . . .
; -----------------------------------------------------------------------------
Enumeration
#About
#Exit
#Start
#Stop
#Abort
#Display
#Format
#source
#Compression
#Preview
#SnapShot
#AudioFormat
EndEnumeration
Global name.s
OpenAviLibrary ()
If OpenWindow (0, #CW_USEDEFAULT, #CW_USEDEFAULT, 300, 0, "Video Capture [initialising...]", #PB_Window_SystemMenu)
CreateMenu (0, WindowID (0))
MenuTitle ("&File")
MenuItem (#About, "&About")
MenuBar ()
MenuItem (#Exit, "E&xit")
MenuTitle ("&Control")
MenuItem (#Start, "&Start")
MenuItem(#Stop,"S&top")
MenuItem(#Abort,"A&bort")
MenuBar()
MenuItem (#Display, "&Display")
MenuItem (#Format, "&Format")
MenuItem (#Source, "S&ource")
MenuItem (#Compression, "Co&mpression")
MenuBar ()
MenuItem (#Preview, "&Preview")
MenuItem (#SnapShot, "S&napShot")
MenuItem (#AudioFormat, "&AudioFormat")
SetMenuItemState (0,#Preview, #True)
; Create and init capture window, using current window as parent (required)...
StartCaptureWindow (WindowID (0))
ResizeWindow (0,0,0,capWidth + (GetSystemMetrics_ (#SM_CXBORDER) * 2), capHeight + (GetSystemMetrics_ (#SM_CYBORDER) * 2))
SetWindowText_ (WindowID (0), "Video Capture")
; [Need to grey out menu items not supported...]
If dlgSource = 0
DisableMenuItem (0,#Source, #False)
EndIf
If dlgFormat = 0
DisableMenuItem (0,#Format, #False)
EndIf
If dlgDisplay = 0
DisableMenuItem (0,#Display, #False)
EndIf
Repeat
Debug dlgSource
e = WaitWindowEvent ()
Select e
Case #PB_Event_CloseWindow
Goto Quit
Case #PB_Event_Menu
Select EventMenu ()
Case #About
mes.s="Ported to PureBasic by James @ hi-toro.com," + #CR$
mes+ "from original Visual Basic source by EJ Bantz."+#CR$
mes+ "Just converted and extended to PB4.31 by Falko @ www.falko-pure.de."+#CR$+#CR$
mes+ "Copyright: None, use And distribute freely."
; Converted and extended to PB4.31 from Falko (German Forum)
MessageRequester ("Video Capture", mes, #MB_ICONINFORMATION | #MB_TASKMODAL)
Case #Exit
Goto Quit
Case #Start
Start_Click ()
Case #Stop
capCaptureStop (lwndC)
Case #Abort
capCaptureAbort (lwndC)
Case #Display
Display_Click ()
Case #Format
Format_Click ()
ResizeWindow (0,0,0,capWidth, capHeight)
Case #Source
dlgDisplay=Source_Click ()
Case #Compression
Compression_Click ()
Case #Preview
Status.l=Preview_Click ()
SetMenuItemState (0, #Preview, Status)
Case #SnapShot
SnapShot()
Case #AudioFormat
GetAudioFormat_Click()
EndSelect
EndSelect
ForEver
EndIf
Quit:
EndCaptureWindow (0)
CloseAviLibrary ()
End
Dann möchte ich nichts mehr von Dir hörendeify hat geschrieben:danke für den hinweis! wenn ich weiterkomme bzw nicht weiter komme dann melde ich mich wieder
Code: Alles auswählen
pImage.l = AllocateMemory (Width * Height * 4 + SizeOf(BMPHEADER))
scp.SimpleCapParams
scp\mWidth = Width
scp\mHeight = Height
scp\mTargetBuf = pImage + SizeOf(BMPHEADER) ; Erste Addresse nach dem Header