开发者

How to get metadata from video-movie file using Objective-c?

Any help? Now can 开发者_Go百科get NSSize, duration and its all.


You can do this almost entirely using Spotlight's metadata.

For example, I do the following in one of my apps

MDItemRef fileMetadata=MDItemCreate(NULL,(CFStringRef)eachPath);
NSDictionary *metadataDictionary = (NSDictionary*)MDItemCopyAttributes (fileMetadata,
                                                                                           (CFArrayRef)[NSArray arrayWithObjects:(id)kMDItemPixelHeight,(id)kMDItemPixelWidth,nil]);

This code essentially asks for the pixel width and height for a movie file (to determine if it's the dimension of an HD movie or not is the reason).

The Spotlight Metadata Attributes Reference lists all the available keys for various file types by category. You can probably get the required data this way without doing anything significant, provided that the media type you're examining has a Spotlight plug-in.


This functionality may not be built in (I'm honestly not sure), but I do know of two third-party libraries which can tell you the information you need.

  • VLCKit, the framework being used by the newest beta versions of VLC for Mac.
  • libmediainfo, a multi-purpose library that can read practically any bit of information you need out of practically any media file.

I can go into more depth with how to use either of these, but I'd rather only do so if you end up needing me to. Let me know!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜