gpt4 book ai didi

objective-c - 如何在 Objective C/Cocoa 中获取 quicktime 视频的编解码器信息? (没有 FFMPEG)

转载 作者:搜寻专家 更新时间:2023-10-30 20:01:13 24 4
gpt4 key购买 nike

您好,感谢您的宝贵时间,我正在创建一个应用程序来移动视频文件以供其他应用程序处理。过去,我在ruby中使用mediainfo和ffmpeg来获取每个文件的编解码器信息。然而,我想将所有这些转移到一个漂亮的 cocoa 应用程序中。我搜索了又搜索,但仍然找不到有关如何执行此操作的解决方案(不使用 ffmpeg)。我基本上是在寻找与您在 quicktime 视频检查器窗口 (apple + i) 中获得的完全相同的信息。任何帮助将不胜感激,示例代码更是如此。谢谢。

最佳答案

您可以使用 Spotlight 查询 (NSMetadataQuery),就像 mdls 命令一样:

> mdls ~/Music/iTunes/iTunes\ Media/iTunes\ U/WWDC\ 2011\ Session\ Videos\ -\ HD/1-01\ Apple\ Platforms\ Kickoff.m4v 
kMDItemAudioBitRate = 103
kMDItemAudioChannelCount = 2
kMDItemCodecs = (
AAC,
"H.264"
)
kMDItemContentCreationDate = 2011-07-01 15:49:56 +0000
kMDItemContentModificationDate = 2011-07-01 16:13:39 +0000
kMDItemContentType = "com.apple.m4v-video"
kMDItemContentTypeTree = (
"com.apple.m4v-video",
"public.movie",
"public.audiovisual-content",
"public.data",
"public.item",
"public.content"
)
kMDItemDateAdded = 2011-07-01 16:13:39 +0000
kMDItemDisplayName = "1-01 Apple Platforms Kickoff.m4v"
kMDItemDurationSeconds = 2787.754421087755
kMDItemFSContentChangeDate = 2011-07-01 16:13:39 +0000
kMDItemFSCreationDate = 2011-07-01 15:49:56 +0000
kMDItemFSCreatorCode = "hook"
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "1-01 Apple Platforms Kickoff.m4v
kMDItemFSNodeCount = 1147843844
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 502
kMDItemFSSize = 1147843844
kMDItemFSTypeCode = ""
kMDItemKind = "Video Media"
kMDItemLogicalSize = 1147843844
kMDItemMediaTypes = (
Sound,
Video
)
kMDItemPhysicalSize = 1147846656
kMDItemPixelHeight = 540
kMDItemPixelWidth = 958
kMDItemProfileName = "HD (1-1-1)"
kMDItemStreamable = 0
kMDItemTotalBitRate = 3287
kMDItemVideoBitRate = 3184

或者您可以查看 AVFoundation 框架。

示例代码:

 -(NSDictionary *) metadataForFileAtPath:(NSString *) path {
NSURL *url = [[[NSURL alloc] initFileURLWithPath:path] autorelease];

MDItemRef itemRef = MDItemCreateWithURL(NULL, (CFURLRef)url);
NSArray *attributeNames = (NSArray *)MDItemCopyAttributeNames(itemRef);
NSDictionary *attributes = (NSDictionary *) MDItemCopyAttributes(itemRef, (CFArrayRef) attributeNames);
CFRelease(itemRef);

// probably it is leaking memory (attributeNames and attributes), better check with Instruments

return attributes;
}

关于objective-c - 如何在 Objective C/Cocoa 中获取 quicktime 视频的编解码器信息? (没有 FFMPEG),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6701904/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com