Ryd*_*kay 10
您可以使用VideoToolbox检查iOS设备或Mac是否具有硬件编码支持:
/// Whether or not the current device has an HEVC hardware encoder.
public static let hasHEVCHardwareEncoder: Bool = {
let spec: [CFString: Any]
#if os(macOS)
spec = [ kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder: true ]
#else
spec = [:]
#endif
var outID: CFString?
var properties: CFDictionary?
let result = VTCopySupportedPropertyDictionaryForEncoder(width: 1920, height: 1080, codecType: kCMVideoCodecType_HEVC, encoderSpecification: spec as CFDictionary, encoderIDOut: &outID, supportedPropertiesOut: &properties)
if result == kVTCouldNotFindVideoEncoderErr {
return false // no hardware HEVC encoder
}
return result == noErr
}()
Run Code Online (Sandbox Code Playgroud)
更高级别的检查方法是查看是否AVAssetExportSession支持其中一个HEVC预设:
AVAssetExportSession.allExportPresets().contains(AVAssetExportPresetHEVCHighestQuality)
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅WWDC 2017中的"使用HEIF和HEVC".
| 归档时间: |
|
| 查看次数: |
1419 次 |
| 最近记录: |