gpt4 book ai didi

ios - iOS 13 上的 AVAssetReferenceRestrictions

转载 作者:行者123 更新时间:2023-12-01 16:01:45 25 4
gpt4 key购买 nike

Workspace: 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
};

还有一个 AVAsset的属性定义为:
@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 部分:我是如何在这里结束的?

I've had to examine these because we were able to select a video from UIImagePickerController, then export it in AVURLAsset form to use in AVAssetExportSession. Everything was fine, it was working seamlessly until iOS 13.0. The feature works in the devices with iOS 12.4.1 and below.

The usage of AVAssetReferenceRestrictions is in the initializer of the AVURLAsset, and I believe that the default value has changed and it doesn't let us export anymore.

最佳答案

不是你的错。

直到 2019-06-19,在 Apple referenceRestrictions documentation ,默认值为 forbidNone :

The default value for this property is forbidNone . See AVURLAssetReferenceRestrictionsKey for a full discussion of reference restrictions.



后来这个页面改成了 this :

The default value for this property is defaultPolicy. See AVURLAssetReferenceRestrictionsKey for a full discussion of reference restrictions.



现在的 defaultPolicy 是 forbidLocalReferenceToRemote ,仅在 iOS 13 中可用。

但是,我们有这一段:

For AVURLAsset, this property reflects the value passed in for AVURLAssetReferenceRestrictionsKey, if any.



因此,显然,不传递限制键应该与 forbidNone 相同。 .

你试过这个吗?
let asset = AVURLAsset(url: url, options: nil)

关于ios - iOS 13 上的 AVAssetReferenceRestrictions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58136254/

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