Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
News

Media file meta-data on Windows in Delphi.

Author: Craig Chapman

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 Problem.

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!

The Solution

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ā€¦

MediaExtractor-take2

Conclusion

Always verify your customers requirements before starting work! 1f642-9336350

Thanks for Reading!

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free TrialĀ Ā Ā Upgrade Today

Ā Ā Ā Free Delphi Community EditionĀ Ā Ā Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES