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

笑着哭i 提交于 2019-12-20 03:17:31

问题


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


回答1:


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.




回答2:


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!



来源:https://stackoverflow.com/questions/3023954/how-to-get-metadata-from-video-movie-file-using-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!