|
Post by metro on Oct 2, 2020 19:02:16 GMT -5
Here's a start
I've never played with this so not sure if it's what you are after
[DefineStructs] 'This struct contians info about the device capabilities struct CAPDRIVERCAPS, _ wDeviceIndex as ulong, _ fHasOverlay as boolean, _ fHasDlgVideoSource as boolean, _ fHasDlgVideoFormat as boolean, _ fHasDlgVideoDisplay as boolean, _ fCaptureInitialized as boolean, _ fDriverSuppliesPalettes as boolean, _ hVideoIn as ulong, _ hVideoOut as ulong, _ hVideoExtIn as ulong, _ hVideoExtOut as ulong
'Form created with the help of Freeform 3 v03-27-03 'Generated on Oct 30, 2004 at 10:30:48
[setup.main.Window]
'-----Begin code for #main
nomainwin WindowWidth = 400 WindowHeight = 400 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
button #main.PreOn,"Preview On",[PreOn], UL, 5, 315, 80, 25 button #main.PreOff,"Preview Off",[PreOff], UL, 5, 340, 80, 25 button #main.Con,"Configure",[Con], UL, 90, 315, 98, 25 button #main.help,"Help",[Help], UL, 191, 315, 98, 25 button #main.CapStart,"Start Capture",[CapStart], UL, 295, 315, 88, 50 button #main.CapStill,"Capture Still",[CapStill], UL, 90, 340, 200, 25
'-----End GUI objects code
open "Video Capture Demo" for window_nf as #main #main.PreOff, "!disable" #main, "font ms_sans_serif 10" #main, "trapclose [quit.main]"
'Open up the dll open "AVICAP32.dll" for DLL as #vfw
'Get the Windows handle hWnd = hwnd(#main)
'Set the style for the capture window dwStyle = _WS_VISIBLE OR _WS_CHILD
'Set the capture window name lpszWindowName$ = "Capture Window"
'And finnaly, create the capture window calldll #vfw, "capCreateCaptureWindowA", _ lpszWindowName$ as ptr, _ dwStyle as ulong, _ 40 as long, _ 40 as long, _ 320 as long, _ 240 as long, _ hWnd as ulong, _ 100 as long, _ hWndC as ulong
'This subroutine enumerates the video capture devices and allows the user to select one gosub [ChooseDevice]
'Connect to the device the user specified calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1034 as ulong, _ DevNum as long, _ 0 as long, _ test as long
'If test is 0 then something went wrong if test = 0 then notice "Cannot connect capture device" goto [quit.main] end if
[main.inputLoop] 'wait here for input event wait
[PreOn] 'Turn preview on
#main.PreOff, "!enable" #main.PreOn, "!disable"
wSize = len(CAPDRIVERCAPS.struct)
calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1038 as ulong, _ wSize as long, _ CAPDRIVERCAPS as struct, _ test as long
if CAPDRIVERCAPS.fHasOverlay.struct = 0 then 'This enables preview mode calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1074 as ulong, _ -1 as long, _ 0 as long, _ test as long
'This sets the frame rate to 5. Most devices can handle a frame rate of 5 calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1076 as ulong, _ 66 as long, _ 0 as long, _ test as long else calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1075 as ulong, _ -1 as long, _ 0 as long, _ test as long end if
wait
[PreOff] 'Turn preview off
#main.PreOff, "!disable" #main.PreOn, "!enable"
'This disables preview mode if CAPDRIVERCAPS.fHasOverlay.struct = 0 then 'This enables preview mode calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1074 as ulong, _ 0 as long, _ 0 as long, _ test as long else calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1075 as ulong, _ 0 as long, _ 0 as long, _ test as long end if
wait
[Con] 'Configure capture 'First, get the device capabilities: wSize = len(CAPDRIVERCAPS.struct)
calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1038 as ulong, _ wSize as long, _ CAPDRIVERCAPS as struct, _ test as long
'Form created with the help of Freeform 3 v03-27-03 'Generated on Oct 30, 2004 at 19:59:23
[setup.Configure.Window]
'-----Begin code for #Configure
WindowWidth = 215 WindowHeight = 210 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
button #Configure.Source,"Configure Video Source",[Source], UL, 5, 5, 195, 25 button #Configure.Format,"Configure Video Format",[Format], UL, 5, 42, 195, 25 button #Configure.Display,"Configure Video Display",[Display], UL, 5, 77, 195, 25 button #Configure.Compression,"Configure Video Compression",[Compression], UL, 5, 112, 195, 25 button #Configure.Done,"Done",[Done], UL, 5, 147, 195, 25
'-----End GUI objects code
open "Configure" for dialog_nf as #Configure
'Disable the dialogs the user's device can't do if CAPDRIVERCAPS.fHasDlgVideoSource.struct = 0 then #Configure.Source, "!disable" if CAPDRIVERCAPS.fHasDlgVideoFormat.struct = 0 then #Configure.Format, "!disable" if CAPDRIVERCAPS.fHasDlgVideoDisplay.struct = 0 then #Configure.Display, "!disable"
#Configure, "font ms_sans_serif 10" #Configure, "trapclose [Done]"
[Configure.inputLoop] 'wait here for input event wait
[Source] 'Display the source dialog box
calldll #user32, "SendMessageA",_ hWndC as ulong, _ 1066 as ulong, _ 0 as long, _ 0 as long, _ test as long goto [Done]
[Format] 'Display the format dialog box
calldll #user32, "SendMessageA",_ hWndC as ulong, _ 1065 as ulong, _ 0 as long, _ 0 as long, _ test as long goto [Done]
[Display] 'Display the Display dialog box
calldll #user32, "SendMessageA",_ hWndC as ulong, _ 1067 as ulong, _ 0 as long, _ 0 as long, _ test as long goto [Done]
[Compression] 'Display the compression dialog box
calldll #user32, "SendMessageA",_ hWndC as ulong, _ 1070 as ulong, _ 0 as long, _ 0 as long, _ test as long goto [Done]
[Done] 'Close the dialog box close #Configure goto [main.inputLoop]
[Help] 'display help information
'Form created with the help of Freeform 3 v03-27-03 'Generated on Oct 30, 2004 at 21:12:31
[setup.About.Window]
'-----Begin code for #About
WindowWidth = 300 WindowHeight = 325 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
statictext #About.statictext1, "VidCapLB", 70, 12, 120, 40 statictext #About.statictext2, "Video Capture Demo for Liberty BASIC", 15, 52, 240, 20 statictext #About.statictext3, "© Callum Lowcay 2004", 55, 67, 132, 20 statictext #About.statictext4, "This program is free and open source", 20, 92, 250, 20 Aboutinfo$ ="Click Preview On to turn on the preview" + chr$(13) + _ "Click preview off to turn it off" + chr$(13) + _ "Click Configure to change your capture settings" + chr$(13) + _ "Click Capture Still to capture a still image" + chr$(13) + _ "It will be saved as a bmp" + chr$(13) + _ "Click Start Capture to start video capture" + chr$(13) + _ "Press ESC to stop video capture" + chr$(13) + _ "Captured Video is saved as AVI" statictext #About.statictext5, Aboutinfo$, 2, 117, 288, 145
button #About.OK,"OK",[quit.About], UL, 10, 262, 265, 25
'-----End GUI objects code
open "About VidCapLB" for dialog_nf as #About print #About, "font ms_sans_serif 10" print #About.statictext1, "!font arial 20" print #About, "trapclose [quit.About]"
[About.inputLoop] 'wait here for input event wait
[quit.About] 'End the program close #About goto [main.inputLoop]
[CapStart] 'Start Capturing video
'Tell the user some stuff notice "Note"+chr$(13)+"During video capture, all other applications will be suspended"+chr$(13)+"Press ESC to end capture, you may have to wait a moment before your system starts responding"+chr$(13)+"This is because it takes time to compress the video data" notice "Note"+chr$(13)+"Make sure you have selected the correct options from the"+chr$(13)+"configuration screen, if not, click cancel on the next dialog"+chr$(13)+"You will also need at least 50MB free hard drive space" 'Get the name of the destination file FileDialog "Save As...", "*.avi", FileName$ if FileName$="" then goto [main.inputLoop]
'This allocates 50MB of hard drive space for a capture file calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1046 as ulong, _ 0 as long, _ 52428800 as long, _ test as long
'If the user is out of hard drive space... if test = 0 then notice "Error"+chr$(13)+"Could not allocate hard drive space"+"Make sure you have at lease 50MB free space" goto [quit.main] end if
'This starts the capture, it also jams up all other programs in the system. calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1086 as ulong, _ 0 as long, _ 0 as long, _ test as long
'This saves the video data in the file the user specified calldll #user32, "SendMessageA", _ hWndC as ulong, _ 1047 as ulong, _ 0 as long, _ FileName$ as ptr, _ test as long
'If the user is out of hard drive space... if test = 0 then notice "Error"+chr$(13)+"Could not save file, you may not have enough hard drive space" goto [quit.main] end if
'And this gets rid of the capture file, which is no longer needed kill "\CAPTURE.AVI"
wait
[CapStill] 'Capture a still image
'Get a file name from the user FileDialog "Save As...", "*.bmp", FileName$ if FileName$="" then goto [main.inputLoop]
'This captures a frame in the computers RAM calldll #user32, "SendMessageA",_ hWndC as ulong,_ 1085 as ulong,_ 0 as long,_ 0 as long,_ test as long
'This saves that fram to the file the user specified, in BMP format calldll #user32, "SendMessageA",_ hWndC as ulong,_ 1049 as ulong,_ 0 as long,_ FileName$ as ptr,_ test as long
wait
[ChooseDevice]
'This code enumerates the devices and prepares them for display in a listbox dim Devices$(10) lpszName$ = space$(40)+chr$(0) cbName = len(lpszName$) lpszVer$ = space$(40)+chr$(0) cbVer = len(lpszVer$) for wDriverIndex = 0 to 9 calldll #vfw, "capGetDriverDescriptionA",_ wDriverIndex as word, _ lpszName$ as ptr, _ cbName as long, _ lpszVer$ as ptr, _ cbVer as long, _ test as long Devices$(wDriverIndex+1) = lpszName$+" "+lpszVer$ next
'Form created with the help of Freeform 3 v03-27-03 'Generated on Oct 31, 2004 at 11:01:23
[setup.Choose.Window]
'-----Begin code for #Choose
nomainwin WindowWidth = 300 WindowHeight = 345 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
ListboxColor$ = "white" listbox #Choose.devices, Devices$(), [SelectDevice], 5, 52, 280, 230 button #Choose.cancel,"Cancel",[Choose.Cancel], UL, 5, 287, 280, 25 statictext #Choose.statictext8, "Double Click the device you want to use", 5, 5, 250, 20 statictext #Choose.statictext9, "Click cancel to cacel the demo", 5, 22, 250, 20
'-----End GUI objects code
open "Choose Device" for dialog_nf as #Choose print #Choose, "font ms_sans_serif 10" print #Choose, "trapclose [quit.Choose]"
[Choose.inputLoop] 'wait here for input event wait
[SelectDevice] 'Find out what device the user selected
#Choose.devices, "selectionindex? DevNum" DevNum=DevNum-1
goto [quit.Choose]
[Choose.Cancel] 'Cancel program
confirm "Are you sure you want to quit?"; yesno$ if yesno$ = "yes" then close #Choose goto [quit.main] else goto [Choose.inputLoop] end if
[quit.Choose] 'End the program close #Choose return
[quit.main] 'End the program 'This code is essential, without it you get a spectacular crash calldll #user32, "DestroyWindow",_ hWndC as ulong, _ ret as long close #vfw close #main end
|
|