2012-06-23 31 views
0

我有一个面板在我的winform中播放视频选择,而视频播放时,我需要从它抓取帧,这是后按钮单击,并抓取的帧应保存一个文件名。我做了很多研究实现这一点,使用c#获取来自当前呈现视频的图像帧direcshow.net

最初我试图为该特定面板的截图捕获功能,并显示它在一个图片盒。 1.“copyfromscreen()” 2.使用系统消息。 3.drawtobitmap() - 控制特定的,所有这些都不能很好地工作,我对结果不满意。

后来我意识到有DirectShow中Ibasicvideo.getcurrentimage()方法来获取当前帧的渲染video.I一直在寻找一个良好的工作例如互联网,但没成功,我真的很需要帮助,

任何解决方案显示在一个单独的picturebox视频的当前图像是可观的。感谢提前!!!!

回答

1

VMR9Snapper样品看看使用此帖子的链接:take picture from webcam c#

int hr = windowlessCtrl.GetCurrentImage(out currentImage); 
DsError.ThrowExceptionForHR(hr); 

if (currentImage != IntPtr.Zero) 
{ 
    BitmapInfoHeader structure = new BitmapInfoHeader(); 
    Marshal.PtrToStructure(currentImage, structure); 

    bmp = new Bitmap(structure.Width, structure.Height, (structure.BitCount/8) * structure.Width, System.Drawing.Imaging.PixelFormat.Format32bppArgb, new IntPtr(currentImage.ToInt64() + 40)); 
    bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); 

    if (saveFileDialog.ShowDialog() == DialogResult.OK) 
    { 
    bmp.Save(saveFileDialog.FileName.ToString(), System.Drawing.Imaging.ImageFormat.Jpeg); 
    } 
} 
+0

我得到的NullReferenceException当我尝试包括VMR9凝灰岩到我的代码。有没有其他方法? –