Guitarmonster
Member
- Joined
- Mar 24, 2023
- Messages
- 19
- Programming Experience
- 10+
I am designing a simple C# application that is using the Aforge.NET library, I already have all of the FFDSHOW required files in my build folder. The purpose of the application is to scan the video and extract each frame as a bitmap, then it takes that bitmap and analyzes different pixels. The code I am working is pulling frames and converting them to Bitmap objects, then using several GetPixel functions to get pixel color, which is analyzed for brightness. The code detects drops in brightness where the video fades to black, which is usually an indicator of an upcoming commercial break.
In short, my app needs to be able to load a video and extract one or several frames as a Bitmap object. So far it works well, except it won't work for any H.264 videos. I started noticing that MKV files didn't get me anything other than basic stream data, no frames. I tried MP4 and it gave me the same result, which tells me it's an H.264 issue and not a container issue.
Since this doesn't necessarily rely on code but FFDSHOW configuration, I don't think this is a code issue as my code is nearly identical to the sample code released by Aforge.net. Unfortunately, Aforge.net is no longer supported and they have locked their forums, so I have to ask here.
I am looking for a way to make Aforge work for me, or an alternative to what I am trying to do.
This is the code in it's most basic format:
When it runs, it DOES extract the stream information including width, height, and codec name. After that there are zero frames returned. I have been searching the net like crazy and cannot seem to find anyone else with this issue, and I'm seeing a lot of coders using Aforge with FFDSHOW. So I am fairly sure this is a codec configuration issue of some sort. Any direction as to what settings to check, or for a better alternative would be greatly appreciated.
In short, my app needs to be able to load a video and extract one or several frames as a Bitmap object. So far it works well, except it won't work for any H.264 videos. I started noticing that MKV files didn't get me anything other than basic stream data, no frames. I tried MP4 and it gave me the same result, which tells me it's an H.264 issue and not a container issue.
Since this doesn't necessarily rely on code but FFDSHOW configuration, I don't think this is a code issue as my code is nearly identical to the sample code released by Aforge.net. Unfortunately, Aforge.net is no longer supported and they have locked their forums, so I have to ask here.
I am looking for a way to make Aforge work for me, or an alternative to what I am trying to do.
This is the code in it's most basic format:
C#:
// create instance of video reader
VideoFileReader reader = new VideoFileReader( );
// open video file
reader.Open( "test.avi" );
// check some of its attributes
Console.WriteLine( "width: " + reader.Width );
Console.WriteLine( "height: " + reader.Height );
Console.WriteLine( "fps: " + reader.FrameRate );
Console.WriteLine( "codec: " + reader.CodecName );
// read 100 video frames out of it
for ( int i = 0; i < 100; i++ )
{
Bitmap videoFrame = reader.ReadVideoFrame( );
// process the frame somehow
// ...
// dispose the frame when it is no longer required
videoFrame.Dispose( );
}
reader.Close( );
When it runs, it DOES extract the stream information including width, height, and codec name. After that there are zero frames returned. I have been searching the net like crazy and cannot seem to find anyone else with this issue, and I'm seeing a lot of coders using Aforge with FFDSHOW. So I am fairly sure this is a codec configuration issue of some sort. Any direction as to what settings to check, or for a better alternative would be greatly appreciated.