I've been attempting to write code that returns the byte data of a thumbnail for the very first frame of a local video file for a few days now with no success. No GUI or rendering is required for this particular bit of code - I simply need to get a thumbnail of the very first video frame, and get the byte data of that thumbnail. (For context, I'm writing a Flutter plugin that will call this code through a method channel - it will pass in the file path, and the bytes of the thumbnail are expected to be returned from the method channel call)
I have attempted to do this with no success using the MediaFoundation library, relying on the confusing code in this example provided by Microsoft. (It is confusing to me because, as I mentioned above, I don't need to render the thumbnail on the screen, nor do I need more than one thumbnail from the video - I only need the very first.) After spending many hours over the course of several days fighting with this code, I've come to the conclusion that this library is not useful for me since it seems to involve rendering in some way at every level - even the GetDIBits
function, which appears to be the best way to get the bits out of a Bitmap, relies upon having a handle, which seems to come from the existing application Window, which is not present in my particular case.
I have scoured the internet looking for a simple way to accomplish doing this and have come up with nothing. I've read so many forum posts and documentation from Microsoft, and the whole thing is driving me absolutely crazy! There must be a simple solution to this problem, right? There has to be a way to do this that doesn't involve rendering.
I've also tried working with std::fstream
with no success.