/// <summary> /// 视频信息浏览 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonVideoInfoScan_Click(object sender, EventArgs e) { try { Microsoft.DirectX.AudioVideoPlayback.Video video = new Video(videoFileName); double frameRate = 1 / video.AverageTimePerFrame; //////////////////////////////////////////////////////////////////////////在控件中进行视频浏览 WinStructs.VIDEOBASICINFO videoBasicInfo; videoBasicInfo = FrameGrabber.GetVideoBasicInfo(videoFileName); if (videoBasicInfo.totalFrames == 0) { throw new ArgumentException("Total Frames is 0!"); } int intervalFrameNum = Convert.ToInt32(textBox_IntervalNum.Text.Trim()); for (int i = 1; i <= videoBasicInfo.totalFrames; i += intervalFrameNum) { this.pictureBox1.Refresh(); this.pictureBox1.Image = FrameGrabber.GetFrameFromVideo(videoBasicInfo.fileName, i, Size.Empty, string.Empty); this.pictureBox1.Image.Save("D:\\frames\\" + i.ToString() + ".bmp"); } } catch (VideoAnalysisProcessSystem.ClassFile.InvalidVideoFileException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (StackOverflowException) { MessageBox.Show("The target image size is too big", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }