使用AForge.Video.FFMPEG时参数无效

时间:2013-05-06 17:40:05

标签: c# .net

我正致力于检测视频文件中的动作的应用程序。我希望通过以下方式做到这一点:

  1. 从硬盘上读取视频。
  2. 将其转换为帧或图像数组(例如位图阵列)。
  3. 对帧进行一些处理,包括通过减去图像来检测运动。
  4. 将处理后的图像保存为视频文件。
  5. 在表单上播放该视频文件。
  6. 我谷歌找到将视频转换为图像数组的好方法。但经过搜索,我认为使用FFMPEG来读取和转换视频。 因为我使用C#我尝试使用AForge。

    有关该课程http://www.aforgenet.com/framework/docs/html/47582d8a-2eeb-03cf-03d5-de3e745a8a34.htm的信息的链接?

    当我尝试使用VideoFileSource类来重新添加视频并将其显示在pictureBox中时,我的问题出现了。但是当我尝试运行程序时,

    中的参数无效
    Application.Run(new Form1());
    

    我的代码::

    public partial class Form1 : Form    
    {
      System.Windows.Forms.Timer timer;
      string fileName;
      VideoFileSource videoSource;
      Thread myThread;
      public Form1()
      {
         InitializeComponent();
      }
        private void Form1_Load(object sender, EventArgs e)
      {
         OpenFileDialog openFiel = new OpenFileDialog();
         if (openFiel.ShowDialog() == DialogResult.OK)
         {
            fileName = openFiel.FileName;
         }
    
         // create video source
         videoSource = new VideoFileSource(fileName);
         // set NewFrame event handler
         videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
         // start the video source
         videoSource.Start();
      }
    
    
      // New frame event handler, which is invoked on each new available video frame
      private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
      {
         // get new frame
         Bitmap bitmap = eventArgs.Frame;
         pictureBox1.Image = bitmap;
         // process the frame
      }     
      private void button1_Click(object sender, EventArgs e)
      {
    
      }
    

    }

1 个答案:

答案 0 :(得分:2)

遇到同样的问题。我发现使用

(Bitmap)eventArgs.Frame.Clone() 

解决问题:)

相关问题