О Bitmap frame = new Bitmap (files [index]) - PullRequest
1 голос
/ 31 января 2020

Я написал некоторое программное обеспечение, которое записывает с программного обеспечения камер Gig-E необработанную запись с помощью streamwriter, и мое программное обеспечение может отображать записанное видео с помощью потокового считывателя.

Теперь, в этой части моего программного обеспечения, я хочу изменить записанное видео на .mp4 для показа в обычном видеоплеере, но моя Visual Studio выдает эту ошибку:

Произошло необработанное исключение типа 'System.ArgumentException' в System.Drawing.dll

Дополнительная информация: параметр недействителен.

Код:

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");
}
}
...