ios - 在objective C中判断mp4是音频还是视频

标签 ios objective-c

由于 mp4 是一种容器文件格式,它可以存储音频和视频文件。我正在努力寻找的是它真正的媒体类型。 (无论是音频还是视频)这可以在 IOS 中完成( objective-c )吗?

最佳答案

AVAsset *asset = [AVAsset assetWithURL:<URL to mp4>];
BOOL hasVideo = [asset tracksWithMediaType:AVMediaTypeVideo].count > 0;
BOOL hasAudio = [asset tracksWithMediaType:AVMediaTypeAudio].count > 0;

关于ios - 在objective C中判断mp4是音频还是视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19654454/

相关文章:

ios - 我可以拥有一个部分在 Swift 中实现,部分在 Objective C 中实现的类吗?

objective-c - iAd for Landscape only 应用程序抛出错误

iphone - 使用 drawRect 为 UIButton 的标签添加下划线

ios - MPInlineVideoFullscreenViewController 在 iPhone 6/iOS 8 中使用 UIWebView 旋转

ios - 如何保存选中的MKAnnotation?

c# - MonoTouch : Where is Frame. 来源?

ios - 如何使用 mapView 和 CLLocationManager 在 iOS Swift 中绘制两个位置之间的方向

ios - 我无法将数据发送到下一个 UIViewController

ios8 Playground 编辑器不可见

ios - Xcode-sqlite3.dylib : illegal multi-thread access to database connection