Reputation: 11
I use Accord.Video.FFMPEG to extract images every 10 frames from a video. Total frames for this video is 38194 frames. First run is good, I can save image every 10 frames but after run of about 38185 frames i got null return from this code Bitmap bmpBaseOriginal = vReader.ReadVideoFrame();
, if I see in the video there is no problem at the end of video.
I do something like this
using (var vReader = new VideoFileReader())
{
vReader.Open(files[0]);
TotalFrame = vReader.FrameCount;
countin = Convert.ToInt32(TotalFrame / Convert.ToDouble(countAsset));
Fps = vReader.FrameRate.Value;
int a = 0;
for (int i = 0; i < vReader.FrameCount; i++)
{
if(i < vReader.FrameCount - 1)
{
Bitmap bmpBaseOriginal = vReader.ReadVideoFrame();
if (i%10 == 0)
{
a++;
bmpBaseOriginal.Save(string.Format("{0}\\{1}.jpeg", dirVideo.FullName, a), ImageFormat.Jpeg);
}
bmpBaseOriginal.Dispose();
}
else
{
a++;
Bitmap bmpBaseOriginal = vReader.ReadVideoFrame();
bmpBaseOriginal.Save(string.Format("{0}\\{1}.jpeg", dirVideo.FullName, a), ImageFormat.Jpeg);
bmpBaseOriginal.Dispose();
}
}
vReader.Close();
}
this problem occurs again on another video if the video has a lot of frames, but no problem if the video has a less frames.
How to solve it?
Upvotes: 1
Views: 296