善良的白兰地 2017-03-23 03:07 采纳率: 0%
浏览 1009

directShow操作demo,获取视频信息时报错,尝试读取或写入受保护的内存

WinStructs.VIDEOINFOHEADER videoInfo = (WinStructs.VIDEOINFOHEADER)Marshal.PtrToStructure(mediaType.pbFormat, typeof(WinStructs.VIDEOINFOHEADER));
其中mediaType.pbFormat是获取到的视频指针,转换成WinStructs.VIDEOINFOHEADER结构体

WinStructs.VIDEOINFOHEADER为创建好的结构体内容如下:
public class WinStructs
{
///
/// The VIDEOINFOHEADER structure describes the bitmap and color information for a video image
///
[StructLayout(LayoutKind.Sequential)]
public struct VIDEOINFOHEADER
{
/// RECT structure that specifies the source video window. This structure can be a clipping rectangle, to select a portion of the source video stream.
public RECT rcSource;
/// RECT structure that specifies the destination video window.
public RECT rcTarget;
/// Approximate data rate of the video stream, in bits per second
public uint dwBitRate;
/// Data error rate, in bit errors per second
public uint dwBitErrorRate;
/// The desired average display time of the video frames, in 100-nanosecond units. The actual time per frame may be longer. See Remarks.
public long AvgTimePerFrame;
/// BITMAPINFOHEADER structure that contains color and dimension information for the video image bitmap. If the format block contains a color table or color masks, they immediately follow the bmiHeader member. You can get the first color entry by casting the address of member to a BITMAPINFO pointer
public BITMAPINFOHEADER bmiHeader;
}

    [StructLayout(LayoutKind.Sequential)]
    public struct RECT
    {
        int left;
        int top;
        int right;
        int bottom;
    }

    /// <summary>
    /// The BITMAPINFOHEADER structure contains information about the dimensions and color format of a device-independent bitmap (DIB). 
    /// SEE MSDN
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct BITMAPINFOHEADER
    {
        /// <summary>Specifies the number of bytes required by the structure. This value does not include the size of the color table or the size of the color masks, if they are appended to the end of structure. See Remarks.</summary>
        public uint biSize;
        /// <summary>Specifies the width of the bitmap, in pixels. For information about calculating the stride of the bitmap, see Remarks.</summary>
        public int biWidth;
        /// <summary>Specifies the height of the bitmap, in pixels. SEE MSDN</summary>
        public int biHeight;
        /// <summary>Specifies the number of planes for the target device. This value must be set to 1</summary>
        public ushort biPlanes;
        /// <summary>Specifies the number of bits per pixel (bpp).  For uncompressed formats, this value gives to the average number of bits per pixel. For compressed formats, this value gives the implied bit depth of the uncompressed image, after the image has been decoded.</summary>
        public ushort biBitCount;
        /// <summary>For compressed video and YUV formats, this member is a FOURCC code, specified as a DWORD in little-endian order. For example, YUYV video has the FOURCC 'VYUY' or 0x56595559. SEE MSDN</summary>
        public uint biCompression;
        /// <summary>Specifies the size, in bytes, of the image. This can be set to 0 for uncompressed RGB bitmaps</summary>
        public uint biSizeImage;
        /// <summary>Specifies the horizontal resolution, in pixels per meter, of the target device for the bitmap</summary>
        public int biXPelsPerMeter;
        /// <summary>Specifies the vertical resolution, in pixels per meter, of the target device for the bitmap</summary>
        public int biYPelsPerMeter;
        /// <summary>Specifies the number of color indices in the color table that are actually used by the bitmap. See Remarks for more information.</summary>
        public uint biClrUsed;
        /// <summary>Specifies the number of color indices that are considered important for displaying the bitmap. If this value is zero, all colors are important</summary>
        public uint biClrImportant;
    }
}

请问哪位大神编一个这个关于视频获取指针的directShow操作demo,编译是可以通过,只是在获取视频信息时报错!网上查说是类型没有指定长度!可长度该怎么指定呢?请大神指教……

  • 写回答

1条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误