OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 5013|回复: 0

emgu VideoWriter写视频问题

[复制链接]
发表于 2011-9-17 21:18:17 | 显示全部楼层 |阅读模式
  1.         private void button3_Click(object sender, EventArgs e)
  2.         {
  3.            OpenFileDialog openFileDialog = new OpenFileDialog();
  4.             openFileDialog.Filter = "AVI文件|*.avi|所有文件|*.*";
  5.            
  6.             if (openFileDialog.ShowDialog() == DialogResult.OK)
  7.             {
  8.                 //axWindowsMediaPlayer1.URL = openFileDialog.FileName;
  9.                 //axWindowsMediaPlayer1.Ctlcontrols.currentPosition = 30;
  10.                filename = openFileDialog.FileName;
  11.                capture = new Capture(filename);
  12.                fourcc = (int)capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FOURCC);
  13.                mythread = new Thread(new ThreadStart(play));
  14.                mythread.Start();   
  15.         
  16.             }
  17.         }
  18.         int fourcc;
  19.         VideoWriter VW;
  20.         //VideoWriter VW = new VideoWriter("example1.avi", CvInvoke.CV_FOURCC('X','V','I','D'),25, 1920, 1080, true);
  21.         bool mark = true;
  22.         Image<Bgr,byte> image;
  23.         IntPtr eof = new IntPtr();
  24.         string str;
  25.        void  play()
  26.         {
  27.             VW = new VideoWriter(&quot;example1.avi&quot;, fourcc, 25, 1920, 1080, true);
  28.             while (mark)
  29.             {
  30.                   image = capture.QueryFrame();
  31.                   if (image == eof)
  32.                   {
  33.                       mark = false;
  34.                       VW.Dispose();               
  35.                   }
  36.                   else
  37.                   {
  38.                       try
  39.                       {
  40.                           imageBox1.Image = image;
  41.                          VW.WriteFrame<Bgr, Byte>(image);
  42.                       }
  43.                       catch
  44.                       {
  45.                           str = Application.ExecutablePath;
  46.                           System.Diagnostics.Process.Start(str);
  47.                           System.Diagnostics.Process.GetCurrentProcess().Kill();   
  48.                           //MessageBox.Show(&quot;请输入正确的3D视频文件&quot;, &quot;提示&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information);
  49.                       }
  50.                  }                                
  51.             }      
  52.         }
复制代码

以安装DivX编码解码器 能正常写出视频 这段程序实质是读取一个avi文件,然后输出一个一模一样的视频example1.avi。
question:写出的视频可以用特定的播放器打开,但无法用自己的程序打开 问题提示“Unable to create capture from file: C:\example1.avi”
capture = new Capture(filename);这句capture返回没NULL

求高手帮忙解决 我怀疑是视频写入不完整 缺少其他的信息 小弟不胜感激
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-4-29 15:19 , Processed in 0.008444 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表