This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Videos have frameCount of -1

Hi Everybody,

I'm an absolute newby here, but have searched around and found nothing to solve this problem. Apologies if I've missed something obvious.

At the moment, I am simply trying to load a video and read it frame by frame. There are several examples of this, and I've copied and pasted. The files seem to load (i.e., no exception is thrown), but then the FrameCount in the Reader is always -1. I've tried this with wmv, mov, and other files.

Here is the smallest sample of code (adapted from the Aurigma documentation):

String fileName = null;
openFileDialog.Filter = "Windows Media Files|*.wmv";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
fileName = openFileDialog.FileName;
}

try
{
//Create the reader
IFormatReader reader = MediaFormatManager.CreateFormatReader(fileName);
//Get the frame
if (reader.FrameCount < 1)
{
Console.WriteLine("File contains no frames.");
return;
}

etc., etc.

Debugging, CreateFormatReader has no problem, but when it gets to check reader.FrameCount, it comes back as -1.

I should say that I'm using Windows 7 64 bit. I've been able to run the BitmapViewer sample, and it's compiling and running without problem. I've also used a number of videos, and they all come back with the same problem.

Any help would be greatly appreciated.

Many thanks in advance,

Jon R
Hello Jonathan,

Thanks for contacting us.

I tried to reproduce your problem. I created simple windows application based on your code listed in the post. It allows loading video files and reading it frame-by-frame. I attached this sample with test wmv file (inside of zip file). Please download and try it out.
If you have any additional questions, I will be glad to assist you.
Hi Dmitry,

Thanks for your response. This is very confusing. Your wmv file worked; however, not one single one that I have works. So, I'm going to try to attach a file that I have problems with (2 Mgbytes, sorry), it plays well in Windows Media Player, but returns a -1 frame count, as do all of my wmv files.

This is very mysterious...

Many thanks,

Jon

Hello Jon,

Most likely, this problem is caused because of you do not have necessary codec installed on your machine.
Unfortunately, I will not be able to assist you with this problem.