- private void button3_Click(object sender, EventArgs e)
- {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.Filter = "AVI文件|*.avi|所有文件|*.*";
-
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- //axWindowsMediaPlayer1.URL = openFileDialog.FileName;
- //axWindowsMediaPlayer1.Ctlcontrols.currentPosition = 30;
- filename = openFileDialog.FileName;
- capture = new Capture(filename);
- fourcc = (int)capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FOURCC);
- mythread = new Thread(new ThreadStart(play));
- mythread.Start();
-
- }
- }
- int fourcc;
- VideoWriter VW;
- //VideoWriter VW = new VideoWriter("example1.avi", CvInvoke.CV_FOURCC('X','V','I','D'),25, 1920, 1080, true);
- bool mark = true;
- Image<Bgr,byte> image;
- IntPtr eof = new IntPtr();
- string str;
- void play()
- {
- VW = new VideoWriter("example1.avi", fourcc, 25, 1920, 1080, true);
- while (mark)
- {
- image = capture.QueryFrame();
- if (image == eof)
- {
- mark = false;
- VW.Dispose();
- }
- else
- {
- try
- {
- imageBox1.Image = image;
- VW.WriteFrame<Bgr, Byte>(image);
- }
- catch
- {
- str = Application.ExecutablePath;
- System.Diagnostics.Process.Start(str);
- System.Diagnostics.Process.GetCurrentProcess().Kill();
- //MessageBox.Show("请输入正确的3D视频文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- }
复制代码
以安装DivX编码解码器 能正常写出视频 这段程序实质是读取一个avi文件,然后输出一个一模一样的视频example1.avi。
question:写出的视频可以用特定的播放器打开,但无法用自己的程序打开 问题提示“Unable to create capture from file: C:\example1.avi”
capture = new Capture(filename);这句capture返回没NULL
求高手帮忙解决 我怀疑是视频写入不完整 缺少其他的信息 小弟不胜感激 |