How to get metadata from video-movie file using Ob

2019-02-27 01:28发布

Any help? Now can get NSSize, duration and its all.

2条回答
ゆ 、 Hurt°
2楼-- · 2019-02-27 01:38

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!

查看更多
The star\"
3楼-- · 2019-02-27 01:53

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.

查看更多
登录 后发表回答