我编写了一些软件,从 Gig-E 相机软件记录流式写入器的原始数据,我的软件可以通过流式读取器显示录制的视频。
现在,在我的软件的这一部分中,我想将录制的视频更改.mp4
为在普通视频播放器中显示,但我的 Visual Studio 给出了这个错误:
System.Drawing.dll 中出现“System.ArgumentException”类型的未处理异常
附加信息:参数无效。
代码:
private void DownloadVideo()
{
int selectedRow = utility.GetSelectedRow(this.dataGridView1);
if (selectedRow == -1)
return;
string path = Directory.GetCurrentDirectory() + "\saved\" + ((string) this.dataGridView1.Rows[selectedRow].Cells[1].Value).ToString();
string currentDirectory = Directory.GetCurrentDirectory();
if (this.saveFileDialog1.ShowDialog() == DialogResult.Cancel)
{
Directory.SetCurrentDirectory(currentDirectory);
}
else
{
Directory.SetCurrentDirectory(currentDirectory);
string fileName = this.saveFileDialog1.FileName;
string[] files = Directory.GetFiles(path);
int width = 800;
int height = 600;
VideoFileWriter videoFileWriter = new VideoFileWriter();
videoFileWriter.Open(fileName, width, height, 25, VideoCodec.MPEG4);
TimeSpan timestamp = new TimeSpan(0, 0, 0, 10);
for (int index = 0; index < files.Length; ++index)
{
Bitmap frame = new Bitmap(files[index]);
videoFileWriter.WriteVideoFrame(frame, timestamp);
}
videoFileWriter.Close();
int num = (int) MessageBox.Show("successfully saved");
}
}