Guitarmonster
Member
- Joined
- Mar 24, 2023
- Messages
- 19
- Programming Experience
- 10+
I have a media player project that I am developing in c# and am looking for something that can give me the ability to extract single frames from a video as quickly as possible. The entire purpose is simply for my code to analyze a tv show episode, and search for spots where commercials are going to begin and end.
Here is what I have done so far. I am using Accord.Net to open a video file, then iterate through one frame per second converting that frame to a Bitmap object, then establishing a 10x10 pixel grid to "sample" the pixels and measure their brightness. The purpose of this is for my code to look for the "drop out" where the screen fades to black, leading to the commercial part of the video. So far my test code works nearly perfectly and is highly accurate, however, using Accord.Net is extremely slow, especially for MKV (h264) files.
There is a discussion of this project at the following thread:
Aforge only working for certain videos, when extracting frames as bitmaps
At this point I am playing around in Windows Presentation Foundation using the .Net framework 4.8. If there is a newer application type I should be using please let me know and I will switch. I am looking for performance to be number one. So far WPF has demonstrated great performance with playing video as well as applying pixel shader effects to the video, but I am certainly open to a better option if needed.
The real thing is finding a way to replace Accord.Net, which uses FFMPEG to extract data. Under the Accord.Net framework, there is supposed to be a way to extract single frames as raw bitmaps, which another designer tells me should be faster. However, it seems that this specific override in Accord either has a design bug, or has not yet been completed, so the only option is to extract actual Bitmap objects themselves.
I'm a very well seasoned programmer, but graphics is not my biggest subject.
As a side note, I am also considering analyzing the audio of the file instead and looking for audio drop outs that are consistent with a program change, then having my code do second confirmation by analyzing only those select frames as well.
Here is what I have done so far. I am using Accord.Net to open a video file, then iterate through one frame per second converting that frame to a Bitmap object, then establishing a 10x10 pixel grid to "sample" the pixels and measure their brightness. The purpose of this is for my code to look for the "drop out" where the screen fades to black, leading to the commercial part of the video. So far my test code works nearly perfectly and is highly accurate, however, using Accord.Net is extremely slow, especially for MKV (h264) files.
There is a discussion of this project at the following thread:
Aforge only working for certain videos, when extracting frames as bitmaps
At this point I am playing around in Windows Presentation Foundation using the .Net framework 4.8. If there is a newer application type I should be using please let me know and I will switch. I am looking for performance to be number one. So far WPF has demonstrated great performance with playing video as well as applying pixel shader effects to the video, but I am certainly open to a better option if needed.
The real thing is finding a way to replace Accord.Net, which uses FFMPEG to extract data. Under the Accord.Net framework, there is supposed to be a way to extract single frames as raw bitmaps, which another designer tells me should be faster. However, it seems that this specific override in Accord either has a design bug, or has not yet been completed, so the only option is to extract actual Bitmap objects themselves.
I'm a very well seasoned programmer, but graphics is not my biggest subject.
As a side note, I am also considering analyzing the audio of the file instead and looking for audio drop outs that are consistent with a program change, then having my code do second confirmation by analyzing only those select frames as well.