在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
C#写的一个视频转换解码器
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Drawing; 6 using System.Runtime.InteropServices; 7 using System.Threading; 8 using System.Windows.Forms; 9 using System.IO; 10 11 namespace Basic 12 { 13 public class VideoAPI //视频API类 14 { 15 // 视频API调用 16 [DllImport("avicap32.dll")]//包含了执行视频捕获的函数,它给AVI文件I/O和视频、音频设备驱动程序提供一个高级接口 17 public static extern IntPtr capCreateCaptureWindow(string lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hwndParent, int nID); 18 [DllImport("AVICAP32.dll", CharSet = CharSet.Unicode)] 19 public static extern bool capGetDriverDescription(int wDriverIndex, StringBuilder lpszName, int cbName, StringBuilder lpszVer, int cbVer); 20 [DllImport("avicap32.dll")] 21 public static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, int nID); 22 [DllImport("avicap32.dll")] 23 public static extern bool capGetDriverDescriptionA(short wDriver, byte[] lpszName, int cbName, byte[] lpszVer, int cbVer); 24 [DllImport("User32.dll")] 25 public static extern bool SendMessage(IntPtr hWnd, int wMsg, bool wParam, int lParam); 26 [DllImport("User32.dll")] 27 public static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, int lParam); 28 [DllImport("User32.dll")] 29 public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); 30 [DllImport("User32.dll")] 31 public static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, FrameEventHandler lParam); 32 [DllImport("User32.dll")] 33 public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, ref BITMAPINFO lParam); 34 [DllImport("User32.dll")] 35 public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, ref CAPDRIVERCAPS lParam); 36 [DllImport("User32.dll")] 37 public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, ref CAPTUREPARMS lParam); 38 [DllImport("User32.dll")] 39 public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, ref CAPSTATUS lParam); 40 [DllImport("User32.dll")] 41 public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags); 42 [DllImport("avicap32.dll")] 43 public static extern int capGetVideoFormat(IntPtr hWnd, IntPtr psVideoFormat, int wSize); 44 45 // 常量 46 // public const int WM_USER = 0x400; 47 public const int WS_CHILD = 0x40000000; 48 public const int WS_VISIBLE = 0x10000000; 49 50 public const int SWP_NOMOVE = 0x2; 51 public const int SWP_NOZORDER = 0x4; 52 // public const int WM_CAP_DRIVER_CONNECT = WM_USER + 10; 53 // public const int WM_CAP_DRIVER_DISCONNECT = WM_USER + 11; 54 public const int WM_CAP_SET_CALLBACK_FRAME = WM_USER + 5; 55 // public const int WM_CAP_SET_PREVIEW = WM_USER + 50; 56 // public const int WM_CAP_SET_PREVIEWRATE = WM_USER + 52; 57 // public const int WM_CAP_SET_VIDEOFORMAT = WM_USER + 45; 58 // public const int WM_CAP_START = WM_USER; 59 public const int WM_CAP_SAVEDIB = WM_CAP_START + 25; 60 61 public const string avicap32 = "avicap32.dll"; 62 public const int WM_USER = 1024; 63 /// <summary> 64 ///WM_CAP_START=WM_USER=1024 65 /// </summary> 66 public const int WM_CAP_START = WM_USER; 67 68 // start of unicode messages 69 /// <summary> 70 /// 开始 WM_USER + 100=1124 71 /// </summary> 72 public const int WM_CAP_UNICODE_START = WM_USER + 100; //开始 1124 73 /// <summary> 74 /// /获得 CAPSTR EAMPTR 75 /// WM_CAP_START + 1=1025 76 /// </summary> 77 public const int WM_CAP_GET_CAPSTREAMPTR = (WM_CAP_START + 1); //获得 CAPSTR EAMPTR 78 /// <summary> 79 /// 设置收回错误 WM_CAP_START + 2=1026 80 /// </summary> 81 public const int WM_CAP_SET_CALLBACK_ERROR = (WM_CAP_START + 2); //设置收回错误 82 /// <summary> 83 /// 设置收回状态 WM_CAP_START + 3=1027 84 /// </summary> 85 public const int WM_CAP_SET_CALLBACK_STATUS = (WM_CAP_START + 3); //设置收回状态 86 /// <summary> 87 /// 设置收回出产 WM_CAP_START + 4=1028 88 /// </summary> 89 public const int WM_CAP_SET_CALLBACK_YIELD = (WM_CAP_START + 4); //设置收回出产 90 /// <summary> 91 /// 设置收回结构 WM_CAP_START + 5=1029 92 /// </summary> 93 public const int WM_CAP_SET_CALLBACK_FRame = (WM_CAP_START + 5); //设置收回结构 94 /// <summary> 95 /// 设置收回视频流 WM_CAP_START + 6=1030 96 /// </summary> 97 public const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = (WM_CAP_START + 6); //设置收回视频流 98 /// <summary> 99 /// 设置收回视频波流 WM_CAP_START +7=1031 100 /// </summary> 101 public const int WM_CAP_SET_CALLBACK_WAVESTREAM = (WM_CAP_START + 7); //设置收回视频波流 102 /// <summary> 103 /// 获得使用者数据 WM_CAP_START + 8=1032 104 /// </summary> 105 public const int WM_CAP_GET_USER_DATA = (WM_CAP_START + 8); //获得使用者数据 106 /// <summary> 107 /// 设置使用者数据 WM_CAP_START + 9=1033 108 /// </summary> 109 public const int WM_CAP_SET_USER_DATA = (WM_CAP_START + 9); //设置使用者数据 110 /// <summary> 111 /// 驱动程序连接 WM_CAP_START + 10=1034 112 /// </summary> 113 public const int WM_CAP_DRIVER_CONNECT = (WM_CAP_START + 10); //驱动程序连接 114 /// <summary> 115 /// 断开启动程序连接 WM_CAP_START + 11=1035 116 /// </summary> 117 public const int WM_CAP_DRIVER_DISCONNECT = (WM_CAP_START + 11); //断开启动程序连接 118 /// <summary> 119 /// 获得驱动程序名字 WM_CAP_START + 12=1036 120 /// </summary> 121 public const int WM_CAP_DRIVER_GET_NAME = (WM_CAP_START + 12); //获得驱动程序名字 122 /// <summary> 123 /// 获得驱动程序版本 WM_CAP_START + 13=1037 124 /// </summary> 125 public const int WM_CAP_DRIVER_GET_VERSION = (WM_CAP_START + 13); //获得驱动程序版本 126 /// <summary> 127 /// 获得驱动程序帽子 WM_CAP_START + 14=1038 128 /// </summary> 129 public const int WM_CAP_DRIVER_GET_CAPS = (WM_CAP_START + 14); //获得驱动程序帽子 130 /// <summary> 131 /// 设置捕获文件 WM_CAP_START + 20=1044 132 /// </summary> 133 public const int WM_CAP_FILE_SET_CAPTURE_FILE = (WM_CAP_START + 20); //设置捕获文件 134 /// <summary> 135 /// 获得捕获文件 WM_CAP_START + 21=1045 136 /// </summary> 137 public const int WM_CAP_FILE_GET_CAPTURE_FILE = (WM_CAP_START + 21); //获得捕获文件 138 /// <summary> 139 /// 另存文件为 WM_CAP_START + 23=1047 140 /// </summary> 141 public const int WM_CAP_FILE_SAVEAS = (WM_CAP_START + 23); //另存文件为 142 /// <summary> 143 /// 保存文件 WM_CAP_START + 25=1049 144 /// </summary> 145 public const int WM_CAP_FILE_SAVEDIB = (WM_CAP_START + 25); //保存文件 146 147 // out of order to save on ifdefs 148 /// <summary> 149 /// 分派文件 WM_CAP_START + 22=1044 150 /// </summary> 151 public const int WM_CAP_FILE_ALLOCATE = (WM_CAP_START + 22); //分派文件 152 /// <summary> 153 /// 设置开始文件 WM_CAP_START + 24=1046 154 /// </summary> 155 public const int WM_CAP_FILE_SET_INFOCHUNK = (WM_CAP_START + 24); //设置开始文件 156 /// <summary> 157 /// 编辑复制 WM_CAP_START + 30=1054 158 /// </summary> 159 public const int WM_CAP_EDIT_COPY = (WM_CAP_START + 30); //编辑复制 160 /// <summary> 161 /// 设置音频格式 WM_CAP_START + 35=1059 162 /// </summary> 163 public const int WM_CAP_SET_AUDIOFORMAT = (WM_CAP_START + 35); //设置音频格式 164 /// <summary> 165 /// 捕获音频格式 WM_CAP_START + 36=1060 166 /// </summary> 167 public const int WM_CAP_GET_AUDIOFORMAT = (WM_CAP_START + 36); //捕获音频格式 168 /// <summary> 169 /// 打开视频格式设置对话框 WM_CAP_START + 41=1065 170 /// </summary> 171 public const int WM_CAP_DLG_VIDEOFORMAT = (WM_CAP_START + 41); //1065 打开视频格式设置对话框 172 /// <summary> 173 /// 打开属性设置对话框,设置对比度、亮度等 WM_CAP_START + 42=1066 174 /// </summary> 175 public const int WM_CAP_DLG_VIDEOSOURCE = (WM_CAP_START + 42); //1066 打开属性设置对话框,设置对比度、亮度等。 176 /// <summary> 177 /// 打开视频显示 WM_CAP_START + 43=1067 178 /// </summary> 179 public const int WM_CAP_DLG_VIDEODISPLAY = (WM_CAP_START + 43); //1067 打开视频显示 180 /// <summary> 181 /// 获得视频格式 WM_CAP_START + 44=1068 182 /// </summary> 183 public const int WM_CAP_GET_VIDEOFORMAT = (WM_CAP_START + 44); //1068 获得视频格式 184 /// <summary> 185 /// 设置视频格式 WM_CAP_START + 45=1069 186 /// </summary> 187 public const int WM_CAP_SET_VIDEOFORMAT = (WM_CAP_START + 45); //1069 设置视频格式 188 /// <summary> 189 /// 打开压缩设置对话框 WM_CAP_START + 46=1070 190 /// </summary> 191 public const int WM_CAP_DLG_VIDEOCOMPRESSION = (WM_CAP_START + 46); //1070 打开压缩设置对话框 192 /// <summary> 193 /// 设置预览 WM_CAP_START + 50=1074 194 /// </summary> 195 public const int WM_CAP_SET_PREVIEW = (WM_CAP_START + 50); //设置预览 196 /// <summary> 197 /// 设置覆盖 WM_CAP_START + 51=1075 198 /// </summary> 199 public const int WM_CAP_SET_OVERLAY = (WM_CAP_START + 51); //设置覆盖 200 /// <summary> 201 /// 设置预览比例 WM_CAP_START + 52=1076 202 /// </summary> 203 public const int WM_CAP_SET_PREVIEWRATE = (WM_CAP_START + 52); //设置预览比例 204 /// <summary> 205 /// 设置刻度 WM_CAP_START + 53=1077 206 /// </summary> 207 public const int WM_CAP_SET_SCALE = (WM_CAP_START + 53); //设置刻度 208 /// <summary> 209 /// 获得状态 WM_CAP_START + 54=1078 210 /// </summary> 211 public const int WM_CAP_GET_STATUS = (WM_CAP_START + 54); //获得状态 212 /// <summary> 213 /// 设置卷 WM_CAP_START + 55=1079 214 /// </summary> 215 public const int WM_CAP_SET_SCROLL = (WM_CAP_START + 55); //设置卷 216 /// <summary> 217 /// 逮捕结构 WM_CAP_START + 60=1084 218 /// </summary> 219 public const int WM_CAP_GRAB_FRame = (WM_CAP_START + 60); //逮捕结构 220 /// <summary> 221 /// 停止逮捕结构 WM_CAP_START + 61=1085 222 /// </summary> 223 public const int WM_CAP_GRAB_FRame_NOSTOP = (WM_CAP_START + 61); //停止逮捕结构 224 /// <summary> 225 /// 次序 WM_CAP_START + 62=1086 226 /// </summary> 227 public const int WM_CAP_SEQUENCE = (WM_CAP_START + 62); //次序 228 /// <summary> 229 /// 没有文件 WM_CAP_START + 63=1087 230 /// </summary> 231 public const int WM_CAP_SEQUENCE_NOFILE = (WM_CAP_START + 63); //没有文件 232 /// <summary> 233 /// 设置安装次序 WM_CAP_START + 64=1088 234 /// </summary> 235 public const int WM_CAP_SET_SEQUENCE_SETUP = (WM_CAP_START + 64); //设置安装次序 236 /// <summary> 237 /// 获得安装次序 WM_CAP_START + 65=1089 238 /// </summary> 239 public const int WM_CAP_GET_SEQUENCE_SETUP = (WM_CAP_START + 65); //获得安装次序 240 /// <summary> 241 /// 设置媒体控制接口 WM_CAP_START + 66=1090 242 /// </summary> 243 public const int WM_CAP_SET_MCI_DEVICE = (WM_CAP_START + 66); //设置媒体控制接口 244 /// <summary> 245 /// 获得媒体控制接口 WM_CAP_START + 67=1091 246 /// </summary> 247 public const int WM_CAP_GET_MCI_DEVICE = (WM_CAP_START + 67); //获得媒体控制接口 248 /// <summary> 249 /// 停止 WM_CAP_START + 68=1092 250 /// </summary> 251 pu |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论