Media file meta-data on Windows in Delphi.
Here’s a little Déjà vu for regular readers of my blog.
One of my customers emailed me with an interesting problem this morning.
“I need to be able to peek into a video file, specifically a .mp4 file, and determine if it’s PAL or NTSC.”
This seemed like a fun challenge, so I thought I’d write a helper class to solve it..
The above excerpt is from a blog that I posted a few days ago (here), in which I was able to determine the media file attributes for an mp4 file on Android.
I was very pleased with myself for having written the code sample, and supplied a link to the blog post to my customer. Unfortunately, that customer then replied to my email with words akin to “Who said anything about Android?!” – Realizing that in my morning haste I’d confused two customers and created a solution for the wrong platform, I was of course suitably embarrassed.
My customer wanted to retrieve this information for a media file on the Windows platform!
Finding information on a media file format on Windows did not appear to be as obvious as it was on Android. The solution that I came up with involves a much earlier post on my blog about integrating the Windows Media Player ActiveX control. Using the type library created by importing the ActiveX player control, it’s possible to interrogate any video loaded into a video player. This doesn’t mean that the video player has to be visible either, it can be created at run-time, interrogated, and disposed without ever being placed on a form.
This is not necessarily the best, or ideal solution – if you have a better idea, please get in touch! (Please don’t suggest ffmpeg).
This solution does work however, and so I’ve re-packaged the same sample application as I built for Android, but this time with the Windows code added in using conditional defines…
Always verify your customers requirements before starting work! 🙂
Thanks for Reading!