public static VIDEO_RESOLUTION GetVideoResolutionByIndex(uint resolutionIndex) { VIDEO_RESOLUTION videoResolution = new VIDEO_RESOLUTION(); videoResolution.dwVersion = 1; videoResolution.bCustom = 0; VIDEORESOLUTION resolution = (VIDEORESOLUTION)resolutionIndex; videoResolution.dwVideoResolution = (uint)resolution; string[] resolutions = resolution.ToString().Replace("VIDEORESOLUTION_", "").Split(new string[] { "x", "X" }, StringSplitOptions.None); if (resolutions.Length == 2) { videoResolution.dwWidth = UInt32.Parse(resolutions[0]); videoResolution.dwHeight = UInt32.Parse(resolutions[1]); } return(videoResolution); }
public static VIDEO_RESOLUTION GetVideoResolutionByWidthHeight(uint width, uint height) { VIDEO_RESOLUTION videoResolution = new VIDEO_RESOLUTION(); videoResolution.dwVersion = 1; videoResolution.bCustom = 0; string resolutionName = "VIDEORESOLUTION_" + width + "X" + height; VIDEORESOLUTION resolution = new VIDEORESOLUTION(); if (Enum.TryParse <VIDEORESOLUTION>(resolutionName, out resolution)) { videoResolution.dwVideoResolution = (uint)resolution; string[] resolutions = resolution.ToString().Replace("VIDEORESOLUTION_", "").Split(new string[] { "x", "X" }, StringSplitOptions.None); if (resolutions.Length == 2) { videoResolution.dwWidth = UInt32.Parse(resolutions[0]); videoResolution.dwHeight = UInt32.Parse(resolutions[1]); } } return(videoResolution); }
public LocalStreamer(uint deviceId, IntPtr controlHandle, VIDEOSOURCE videoSource, CAPTURETYPE captureType, uint imageWidth, uint imageHeight, VIDEORESOLUTION resolution, VIDEOFORMAT format = VIDEOFORMAT.VIDEOFORMAT_NTSC) { DeviceId = deviceId; AVerCapAPI.AVerCreateCaptureObjectEx(DeviceId, (uint)captureType, controlHandle, ref _captureObject); var videoResolution = new VIDEO_RESOLUTION() { dwVideoResolution = (uint)resolution, dwVersion = 1 }; AVerCapAPI.AVerSetVideoFormat(_captureObject, (uint)format); AVerCapAPI.AVerSetVideoSource(_captureObject, (uint)videoSource); AVerCapAPI.AVerSetVideoResolutionEx(_captureObject, ref videoResolution); AVerCapAPI.AVerSetVideoRenderer(_captureObject, (uint)VIDEORENDERER.VIDEORENDERER_VMR9); AVerCapAPI.AVerSetVideoPreviewEnabled(_captureObject, 1); AVerCapAPI.AVerSetVideoInputFrameRate(_captureObject, 5900); AVerCapAPI.AVerSetVideoOutputFrameRate(_captureObject, 5900); AVerCapAPI.AVerSetVideoEnhanceMode(_captureObject, (uint)VIDEOENHANCE.VIDEOENHANCE_NONE); AVerCapAPI.AVerSetMaintainAspectRatioEnabled(_captureObject, 1); var rectClient = new RECT { Left = 0, Top = 0, Right = (int)imageWidth, Bottom = (int)imageHeight }; AVerCapAPI.AVerSetVideoWindowPosition(_captureObject, rectClient); }