ios - iOS 13 上的 AVAssetReferenceRestrictions
问题描述
工作区:iOS 13.0、Xcode 11.0
TL;DR:iOS 13 中的 AVAssetReferenceRestrictions 有问题吗?
第1部分:
在AVAsset.h
中,AVAssetReferenceRestrictions
定义为:
@enum AVAssetReferenceRestrictions
@abstract These constants can be passed in to AVURLAssetReferenceRestrictionsKey to control the resolution of references to external media data.
@constant AVAssetReferenceRestrictionForbidNone
Indicates that all types of references should be followed.
@constant AVAssetReferenceRestrictionForbidRemoteReferenceToLocal
Indicates that references from a remote asset (e.g. referenced via http URL) to local media data (e.g. stored in a local file) should not be followed.
@constant AVAssetReferenceRestrictionForbidLocalReferenceToRemote
Indicates that references from a local asset to remote media data should not be followed.
@constant AVAssetReferenceRestrictionForbidCrossSiteReference
Indicates that references from a remote asset to remote media data stored at a different site should not be followed.
@constant AVAssetReferenceRestrictionForbidLocalReferenceToLocal
Indicates that references from a local asset to local media data stored outside the asset's container file should not be followed.
@constant AVAssetReferenceRestrictionForbidAll
Indicates that only references to media data stored within the asset's container file should be allowed.
*/
typedef NS_OPTIONS(NSUInteger, AVAssetReferenceRestrictions) {
AVAssetReferenceRestrictionForbidNone = 0UL,
AVAssetReferenceRestrictionForbidRemoteReferenceToLocal = (1UL << 0),
AVAssetReferenceRestrictionForbidLocalReferenceToRemote = (1UL << 1),
AVAssetReferenceRestrictionForbidCrossSiteReference = (1UL << 2),
AVAssetReferenceRestrictionForbidLocalReferenceToLocal = (1UL << 3),
AVAssetReferenceRestrictionForbidAll = 0xFFFFUL,
AVAssetReferenceRestrictionDefaultPolicy = AVAssetReferenceRestrictionForbidLocalReferenceToRemote
};
并且 anAVAsset
的属性定义为:
@property referenceRestrictions
@abstract Indicates the reference restrictions being used by the receiver.
@discussion
For AVURLAsset, this property reflects the value passed in for AVURLAssetReferenceRestrictionsKey, if any. See AVURLAssetReferenceRestrictionsKey below for a full discussion of reference restrictions. The default value for this property is AVAssetReferenceRestrictionForbidNone.
@property (nonatomic, readonly) AVAssetReferenceRestrictions referenceRestrictions API_AVAILABLE(macos(10.7), ios(5.0), tvos(9.0)) API_UNAVAILABLE(watchos);
因此,尽管该属性的文档明确表示默认值为AVAssetReferenceRestrictionForbidNone
,AVAssetReferenceRestrictionDefaultPolicy
当前为AVAssetReferenceRestrictionForbidLocalReferenceToRemote
. 文档没有正确更新,还是AVAssetReferenceRestrictionDefaultPolicy
与我预期的不同?
第2部分:
在 Swift 对应项中,它是这样定义(转换的?):
@enum AVAssetReferenceRestrictions
@abstract These constants can be passed in to AVURLAssetReferenceRestrictionsKey to control the resolution of references to external media data.
@constant AVAssetReferenceRestrictionForbidNone
Indicates that all types of references should be followed.
@constant AVAssetReferenceRestrictionForbidRemoteReferenceToLocal
Indicates that references from a remote asset (e.g. referenced via http URL) to local media data (e.g. stored in a local file) should not be followed.
@constant AVAssetReferenceRestrictionForbidLocalReferenceToRemote
Indicates that references from a local asset to remote media data should not be followed.
@constant AVAssetReferenceRestrictionForbidCrossSiteReference
Indicates that references from a remote asset to remote media data stored at a different site should not be followed.
@constant AVAssetReferenceRestrictionForbidLocalReferenceToLocal
Indicates that references from a local asset to local media data stored outside the asset's container file should not be followed.
@constant AVAssetReferenceRestrictionForbidAll
Indicates that only references to media data stored within the asset's container file should be allowed.
public struct AVAssetReferenceRestrictions : OptionSet {
public init(rawValue: UInt)
public static var forbidRemoteReferenceToLocal: AVAssetReferenceRestrictions { get }
public static var forbidLocalReferenceToRemote: AVAssetReferenceRestrictions { get }
public static var forbidCrossSiteReference: AVAssetReferenceRestrictions { get }
public static var forbidLocalReferenceToLocal: AVAssetReferenceRestrictions { get }
public static var forbidAll: AVAssetReferenceRestrictions { get }
public static var defaultPolicy: AVAssetReferenceRestrictions { get }
}
这里没有选项AVAssetReferenceRestrictionForbidNone
。但是文档明确表示确实如此。那么,这是谁的错,还是我的误解?
第 3 部分:我是如何在这里结束的?
我不得不检查这些,因为我们能够从中选择一个视频
UIImagePickerController
,然后以AVURLAsset
表格形式将其导出以在AVAssetExportSession
. 一切都很好,直到 iOS 13.0 都可以无缝运行。该功能适用于 iOS 12.4.1 及更低版本的设备。AVAssetReferenceRestrictions 的用法在 的初始化程序中
AVURLAsset
,我相信默认值已经改变,它不再让我们导出。
解决方案
不是你的错。
直到 2019 年 6 月 19 日,在Apple 参考限制文档中,默认值为forbidNone
:
此属性的默认值为 forbidNone 。有关引用限制的完整讨论,请参阅 AVURLAssetReferenceRestrictionsKey。
后来,这个页面变成了这个:
此属性的默认值为defaultPolicy。有关引用限制的完整讨论,请参阅 AVURLAssetReferenceRestrictionsKey。
现在的 defaultPolicy 是forbidLocalReferenceToRemote
,仅在 iOS 13 中可用。
但是,我们有这一段:
对于 AVURLAsset,此属性反映为 AVURLAssetReferenceRestrictionsKey 传入的值(如果有)。
因此,显然,不传递限制键应该与forbidNone
.
你试过这个吗?
let asset = AVURLAsset(url: url, options: nil)
推荐阅读
- python - 是否可以将 _io.TextIOWrapper 变成一个列表?
- python - “RemoteProtocolError:非法请求行”是什么意思?
- google-apps-script - 单击时交换颜色的按钮
- vscode-settings - 有没有办法在打开命令面板时改变它的位置
- python - VAE潜在空间的差异
- javascript - 我需要比较给定数组元素的时间戳,并根据 JavaScript 中的比较将这些元素推送到新数组
- python - 在 ViT 模型的转换器中,last_hidden_state 不等于 hidden_states[-1]
- fpga - Lattice Mach XO2 内部时钟利用率
- oracle - 在 Oracle 12c 的 WHERE 子句中使用 CASE
- javascript - iPhone 上的 Javascript 触控力