找回密码
 加入
搜索
查看: 24270|回复: 50

[转贴] 视频控制

 火... [复制链接]
发表于 2008-5-7 03:41:55 | 显示全部楼层 |阅读模式
直接用API控制视频头的程序。

我经常抽的烟。


相伴我差不多三年的爱机。






$WM_CAP_START = 0x400
$WM_CAP_UNICODE_START = $WM_CAP_START +100
$WM_CAP_PAL_SAVEA = $WM_CAP_START + 81
$WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81
$WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW
$WM_CAP_ABORT = $WM_CAP_START + 69
$WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46
$WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43
$WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41
$WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42
$WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10
$WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11
$WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14
$WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12
$WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12
$WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13
$WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13
$WM_CAP_EDIT_COPY = $WM_CAP_START + 30
$WM_CAP_END = $WM_CAP_UNICODE_END
$WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22
$WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21
$WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21
$WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23
$WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23
$WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25
$WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25
$WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20
$WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20
$WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24
$WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36
$WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1
$WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67
$WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67
$WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65
$WM_CAP_GET_STATUS = $WM_CAP_START + 54
$WM_CAP_GET_USER_DATA = $WM_CAP_START + 8
$WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44
$WM_CAP_GRAB_FRAME = $WM_CAP_START + 60
$WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61
$WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83
$WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84
$WM_CAP_PAL_OPENA = $WM_CAP_START + 80
$WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80
$WM_CAP_PAL_PASTE = $WM_CAP_START + 82
$WM_CAP_SEQUENCE = $WM_CAP_START + 62
$WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63
$WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35
$WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85
$WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2
$WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2
$WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5
$WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3
$WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3
$WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6
$WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7
$WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4
$WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66
$WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66
$WM_CAP_SET_OVERLAY = $WM_CAP_START + 51
$WM_CAP_SET_PREVIEW = $WM_CAP_START + 50
$WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52
$WM_CAP_SET_SCALE = $WM_CAP_START + 53
$WM_CAP_SET_SCROLL = $WM_CAP_START + 55
$WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64
$WM_CAP_SET_USER_DATA = $WM_CAP_START + 9
$WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45
$WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72
$WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71
$WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70
$WM_CAP_STOP = $WM_CAP_START + 68

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)
_Singleton("Camera")
HotKeySet("{f8}", "SnapShot")

$avi = DllOpen("avicap32.dll")
$user = DllOpen("user32.dll")


$Main = GUICreate("视频控制 beta 1.0",550,480)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GuiMsg")
GUICtrlCreateGroup ("", 10, 10, 530, 430)
GUICtrlCreateGroup ("",-99,-99,1,1)
  
$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 25, "int", 25, "int", 500, "int", 400, "hwnd", $Main, "int", 1)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)


$about=GUICtrlCreateButton("程序制作",10,450,80,25)
$SnapShot=GUICtrlCreateButton("拍摄图片",160,450,80,25)

GUICtrlCreateButton("定时自拍",260,450,80,25)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateButton("特效拍摄",360,450,80,25)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateButton("影片拍摄",460,450,80,25)
GUICtrlSetState(-1,$GUI_DISABLE)

GUICtrlSetOnEvent($SnapShot, "SnapShot")
GUICtrlSetOnEvent($about, "_about")

GUISetState(@SW_SHOW)
   

While 1
  
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', @AutoItPID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall("kernel32.dll" , 'int', 'CloseHandle', 'int', $ai_Handle[0])
Sleep(1000)

Wend


Func SnapShot()
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str",@HOUR & "时" &@MIN & "分"& @SEC & "秒"&".bmp")
EndFunc

Func _about()
MsgBox(64,"视频控制","AU3一样可以控制视频:拍摄图片和AVI,不在话下,更多的特效请关注后续更新!")
EndFunc

Func _GuiMsg()

  Switch @GUI_CTRLID
                Case  $GUI_EVENT_CLOSE
                                _ExitMsg()                                            
        Case $GUI_EVENT_MINIMIZE
                guisetstate(@SW_MINIMIZE)
        Case $GUI_EVENT_RESTORE
                guisetstate(@SW_RESTORE)
  EndSwitch
               
EndFunc


Func _ExitMsg()

   DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)
   DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
   DllClose($user)
   Exit

EndFunc



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1威望 +10 金钱 +10 贡献 +10 收起 理由
逍遥子 + 10 + 10 + 10 原创内容,感谢你对论坛的支持;希望继续发 ...

查看全部评分

发表于 2008-5-7 04:11:28 | 显示全部楼层
不错,收下
发表于 2008-5-7 07:37:10 | 显示全部楼层
哇,这是...,下来看看
发表于 2008-5-7 13:09:30 | 显示全部楼层
高手就是不一样
发表于 2008-5-7 16:52:08 | 显示全部楼层
高手出马,一个顶三个!
发表于 2008-5-7 16:55:39 | 显示全部楼层
收藏,要是每条语句能翻译一下就好了。我什么时候能到这个高度。。。。。。
发表于 2008-5-7 17:01:30 | 显示全部楼层
经典收藏了
发表于 2008-5-7 17:05:09 | 显示全部楼层
呵呵,测试通过哈。。不错,,能不能来些拍照的特效。。最好能录像,嘿嘿

[ 本帖最后由 rho123 于 2008-5-7 17:30 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2008-5-10 16:02:05 | 显示全部楼层
好厉害,拍马也敢不上。。。追随前辈的脚步,努力学习。。。。
发表于 2008-5-10 21:23:19 | 显示全部楼层
下载看看, 得的积分...
发表于 2008-5-16 13:14:31 | 显示全部楼层
三恨就是牛!学习一下~以后做个自动上传到网络的出來~嘻嘻~好玩!
发表于 2008-5-16 19:13:25 | 显示全部楼层
很久以前看到过,现在更强大了,我仿佛看到了三狠居士在烟雾缭绕中悠然自得的样子
发表于 2008-5-19 17:16:43 | 显示全部楼层
经典收藏了
发表于 2008-7-8 08:34:33 | 显示全部楼层
看不太明白
发表于 2008-7-18 18:37:10 | 显示全部楼层
果然,当真,高手!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-22 03:59 , Processed in 0.080966 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表