Error with VideoFileReader with Accord.Net Library
What would you like to submit? (put an 'x' inside the bracket that applies)
- [ ] question
- [X ] bug report
- [ ] feature request
Issue description
I am encountering an error and I am unsure how to handle. I am using Accord.Net framework to do some video recording and merging of video files. I have discovered an issue which just closes my application even when in a try/catch block. There are instances where I create video files with a video file writer but may never write a frame. The video file writer is properly closed and it creates a file that is 10kb in size. If I use a VideoFileReader to open that video file it will just crash my application? The behavior I would expect is it to open the file and then have a framecount of 0. Even if I encapsulate the reader's open in a try catch block it never throws exceptions and closes application. Here is some demo code to demonstrate behavior.
//Open writer and close to create an empty 10kb video file
VideoFileWriter writer = new VideoFileWriter();
writer.Height = 1080;
writer.Width = 1920;
writer.FrameRate = 2;
writer.VideoCodec = VideoCodec.Mpeg4;
writer.Open(@"C:\Temp\TestError.avi");
writer.Close();
//Create a file reader and try to read the previously created video file
//Just closes application and no exception
VideoFileReader reader = new VideoFileReader();
try
{
reader.Open(@"C:\Temp\TestError.avi");
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
Console.ReadLine();
Anyone have any ideas on how to handle? I know i can exclude files in 10kb length and smaller but that worries me about issues with larger files in the future?
UPDATE: I have noticed that if I do below I will not get an error when opening but not sure if I should handle it by writing an empty Bitmap every time I instantiate a VideoFileWriter
//No error performing like this
VideoFileWriter writer = new VideoFileWriter();
writer.Height = 1080;
writer.Width = 1920;
writer.FrameRate = 2;
writer.VideoCodec = VideoCodec.Mpeg4;
writer.Open(@"C:\Temp\TestError.avi");
writer.WriteVideoFrame(new Bitmap(1920,1080));
writer.Close();
//No error performing like this
VideoFileReader reader = new VideoFileReader();
try
{
reader.Open(@"C:\Temp\TestError.avi");
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
Console.ReadLine();