📄 vfw.pas
字号:
unit vfw;
interface
uses
Windows, MMSystem, Messages;
const
// ------------------------------------------------------------------
// 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;
// dwFlags field of TVIDEOHDR
VHDR_DONE = $00000001; // Done bit */
VHDR_PREPARED= $00000002; // Set if this header has been prepared */
VHDR_INQUEUE = $00000004; // Reserved for driver */
VHDR_KEYFRAME= $00000008; // Key Frame */
// ------------------------------------------------------------------
// Structures
// ------------------------------------------------------------------
type
PCapDriverCaps = ^TCapDriverCaps;
TCapDriverCaps = record
wDeviceIndex :WORD; // Driver index in system.ini
fHasOverlay :BOOL; // Can device overlay?
fHasDlgVideoSource :BOOL; // Has Video source dlg?
fHasDlgVideoFormat :BOOL; // Has Format dlg?
fHasDlgVideoDisplay :BOOL; // Has External out dlg?
fCaptureInitialized :BOOL; // Driver ready to capture?
fDriverSuppliesPalettes :BOOL; // Can driver make palettes?
hVideoIn :THANDLE; // Driver In channel
hVideoOut :THANDLE; // Driver Out channel
hVideoExtIn :THANDLE; // Driver Ext In channel
hVideoExtOut :THANDLE; // Driver Ext Out channel
end;
pCapStatus = ^TCapStatus;
TCapStatus = record
uiImageWidth :UINT; // Width of the image
uiImageHeight :UINT; // Height of the image
fLiveWindow :BOOL; // Now Previewing video?
fOverlayWindow :BOOL; // Now Overlaying video?
fScale :BOOL; // Scale image to client?
ptScroll :TPOINT; // Scroll position
fUsingDefaultPalette :BOOL; // Using default driver palette?
fAudioHardware :BOOL; // Audio hardware present?
fCapFileExists :BOOL; // Does capture file exist?
dwCurrentVideoFrame :DWORD; // # of video frames cap'td
dwCurrentVideoFramesDropped :DWORD; // # of video frames dropped
dwCurrentWaveSamples :DWORD; // # of wave samples cap'td
dwCurrentTimeElapsedMS :DWORD; // Elapsed capture duration
hPalCurrent :HPALETTE; // Current palette in use
fCapturingNow :BOOL; // Capture in progress?
dwReturn :DWORD; // Error value after any operation
wNumVideoAllocated :UINT; // Actual number of video buffers
wNumAudioAllocated :UINT; // Actual number of audio buffers
end;
pCaptureParms = ^TCaptureParms;
TCaptureParms = record // Default values in parenthesis
dwRequestMicroSecPerFrame :DWORD; // Requested capture rate
fMakeUserHitOKToCapture :BOOL; // Show "Hit OK to cap" dlg?
wPercentDropForError :UINT; // Give error msg if > (10%)
fYield :BOOL; // Capture via background task?
dwIndexSize :DWORD; // Max index size in frames (32K)
wChunkGranularity :UINT; // Junk chunk granularity (2K)
fUsingDOSMemory :BOOL; // Use DOS buffers?
wNumVideoRequested :UINT; // # video buffers, If 0, autocalc
fCaptureAudio :BOOL; // Capture audio?
wNumAudioRequested :UINT; // # audio buffers, If 0, autocalc
vKeyAbort :UINT; // Virtual key causing abort
fAbortLeftMouse :BOOL; // Abort on left mouse?
fAbortRightMouse :BOOL; // Abort on right mouse?
fLimitEnabled :BOOL; // Use wTimeLimit?
wTimeLimit :UINT; // Seconds to capture
fMCIControl :BOOL; // Use MCI video source?
fStepMCIDevice :BOOL; // Step MCI device?
dwMCIStartTime :DWORD; // Time to start in MS
dwMCIStopTime :DWORD; // Time to stop in MS
fStepCaptureAt2x :BOOL; // Perform spatial averaging 2x
wStepCaptureAverageFrames :UINT; // Temporal average n Frames
dwAudioBufferSize :DWORD; // Size of audio bufs (0 = default)
fDisableWriteCache :BOOL; // Attempt to disable write cache
AVStreamMaster :UINT; // Which stream controls length?
end;
PCapInfoChunk = ^TCapInfoChunk;
TCapInfoChunk = record
fccInfoID :FOURCC; // Chunk ID, "ICOP" for copyright
lpData :Pointer; // pointer to data
cbData :LongInt; // size of lpData
end;
PVIDEOHDR = ^TVIDEOHDR;
TVIDEOHDR = record
lpData:pByte; // pointer to locked data buffer
dwBufferLength:DWORD; // Length of data buffer
dwBytesUsed:DWORD; // Bytes actually used
dwTimeCaptured:DWORD; // Milliseconds from start of stream
dwUser:DWORD; // for client's use
dwFlags:DWORD; // assorted flags (see defines)
dwReserved: array [0..4] of DWORD; // reserved for driver
end;
// ------------------------------------------------------------------
// Callback Definitions
// ------------------------------------------------------------------
type
TCAPSTATUSCALLBACK = function(hWnd:HWND; nID:Integer; lpsz:PChar):LongInt; stdcall;
TCAPYIELDCALLBACK = function(hWnd:HWND):LongInt; stdcall;
TCAPERRORCALLBACK = function(hWnd:HWND; nID:Integer; lpsz:Pchar):LongInt; stdcall;
TCAPVIDEOSTREAMCALLBACK = function(hWnd:HWND; lpVHdr:PVIDEOHDR):LongInt; stdcall;
TCAPWAVESTREAMCALLBACK = function(hWnd:HWND; lpWHdr:PWAVEHDR):LongInt; stdcall;
TCAPCONTROLCALLBACK = function(hWnd:HWND; nState:Integer):LongInt; stdcall;
// ------------------------------------------------------------------
// CapControlCallback states
// ------------------------------------------------------------------
Const
CONTROLCALLBACK_PREROLL = 1; // Waiting to start capture
CONTROLCALLBACK_CAPTURING = 2; // Now capturing
// ------------------------------------------------------------------
// Message crackers for above
// ------------------------------------------------------------------
function capSetCallbackOnError (hwnd : THandle; fpProc:TCAPERRORCALLBACK):LongInt;
function capSetCallbackOnStatus(hwnd : THandle; fpProc:TCAPSTATUSCALLBACK):LongInt;
function capSetCallbackOnYield (hwnd : THandle; fpProc:TCAPYIELDCALLBACK):LongInt;
function capSetCallbackOnFrame (hwnd : THandle; fpProc:TCAPVIDEOSTREAMCALLBACK):LongInt; // Hier ist der Type der Callbackfunktion nicht klar !
function capSetCallbackOnVideoStream(hwnd:THandle; fpProc:TCAPVIDEOSTREAMCALLBACK):LongInt;
function capSetCallbackOnWaveStream (hwnd:THandle; fpProc: TCAPWAVESTREAMCALLBACK):LongInt;
function capSetCallbackOnCapControl (hwnd:THandle; fpProc:TCAPCONTROLCALLBACK):LongInt;
function capSetUserData(hwnd:THandle; lUser:LongInt):LongInt;
function capGetUserData(hwnd:THandle):LongInt;
function capDriverConnect(hwnd:THandle; I: Word) : boolean;
function capDriverDisconnect(hwnd:THandle):boolean;
function capDriverGetName(hwnd:THandle; szName:PChar; wSize:Word):boolean;
function capDriverGetVersion(hwnd:THandle; szVer:PChar; wSize:Word):Boolean;
function capDriverGetCaps(hwnd:THandle; s:PCapDriverCaps; wSize:Word):boolean;
function capFileSetCaptureFile(hwnd:THandle; szName:PChar):boolean;
function capFileGetCaptureFile(hwnd:THandle; szName:PChar; wSize:Word):boolean;
function capFileAlloc(hwnd:THandle; dwSize:DWORD):boolean;
function capFileSaveAs(hwnd:THandle; szName:Pchar):boolean;
function capFileSetInfoChunk(hwnd:THandle; lpInfoChunk:pCapInfoChunk):boolean ;
function capFileSaveDIB(hwnd:THandle; szName:Pchar):boolean;
function capEditCopy(hwnd : THandle):boolean;
function capSetAudioFormat(hwnd:THandle; s:PWaveFormatEx; wSize:Word):Boolean;
function capGetAudioFormat(hwnd:THandle; s:PWaveFormatEx; wSize:Word):DWORD;
function capGetAudioFormatSize(hwnd:THandle):DWORD;
function capDlgVideoFormat(hwnd:THandle):boolean;
function capDlgVideoSource(hwnd:THandle):boolean;
function capDlgVideoDisplay(hwnd:THandle):boolean;
function capDlgVideoCompression(hwnd:THandle):boolean;
function capGetVideoFormat(hwnd:THandle; s:pBitmapInfo; wSize:Word):DWord;
function capGetVideoFormatSize(hwnd:THandle):DWORD;
function capSetVideoFormat(hwnd:THandle; s:pBitmapInfo; wSize:Word):boolean;
function capPreview(hwnd:THandle; f:boolean):boolean;
function capPreviewRate(hwnd:THandle; wMS:Word):boolean;
function capOverlay(hwnd:THandle; f:boolean):boolean;
function capPreviewScale(hwnd:THandle; f:boolean):boolean;
function capGetStatus(hwnd:THandle; s:pCapStatus; wSize:Word):boolean;
function capSetScrollPos(hwnd:THandle; lpP:pPoint):boolean;
function capGrabFrame(hwnd:THandle):boolean;
function capGrabFrameNoStop(hwnd:THandle):boolean;
function capCaptureSequence(hwnd:THandle):Boolean;
function capCaptureSequenceNoFile(hwnd:THandle):Boolean;
function capCaptureStop(hwnd:THandle):boolean;
function capCaptureAbort(hwnd:THandle):boolean;
function capCaptureSingleFrameOpen(hwnd:THandle):boolean;
function capCaptureSingleFrameClose(hwnd:THandle):boolean;
function capCaptureSingleFrame(hwnd:THandle):boolean;
function capCaptureGetSetup(hwnd:THandle; s:pCaptureParms; wSize:Word):boolean;
function capCaptureSetSetup(hwnd:THandle; s:pCaptureParms; wSize:Word):boolean;
function capSetMCIDeviceName(hwnd:THandle; szName:PChar):boolean;
function capGetMCIDeviceName(hwnd:THandle; szName:PChar; wSize:Word):boolean;
function capPaletteOpen(hwnd:THandle; szName:PChar):boolean;
function capPaletteSave(hwnd:THandle; szName:PChar):boolean;
function capPalettePaste(hwnd:THandle):Boolean;
function capPaletteAuto(hwnd:THandle; iFrames:Word; iColors:word):boolean;
function capPaletteManual(hwnd:THandle; fGrab:Word; iColors:word):boolean;
// ------------------------------------------------------------------
// The only exported functions from AVICAP.DLL
// ------------------------------------------------------------------
function capCreateCaptureWindow (
lpszWindowName : PChar;
dwStyle : DWord;
x, y : Integer;
nWidth, nHeight : Integer;
hwndParent : THandle;
nID : Integer ) : THandle; stdcall;
function capGetDriverDescription (
wDriverIndex : DWord;
lpszName : PChar;
cbName : Integer;
lpszVer : PChar;
cbVer : Integer ) : Boolean; stdcall;
// ------------------------------------------------------------------
// New Information chunk IDs
// ------------------------------------------------------------------
(*
infotypeDIGITIZATION_TIME = mmioStringToFOURCC(PChar('IDIT'), MMIO_TOUPPER);
infotypeSMPTE_TIME = mmioStringToFOURCC(PChar('ISMP'), MMIO_TOUPPER);
*)
// ------------------------------------------------------------------
// String IDs from status and error callbacks
// ------------------------------------------------------------------
Const
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" *)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -