You can check if an iOS device or Mac has hardware encoding support using VideoToolbox:
/// 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
}()
A much higher level way to check is to see if AVAssetExportSession
supports one of the HEVC presets:
AVAssetExportSession.allExportPresets().contains(AVAssetExportPresetHEVCHighestQuality)
See “Working with HEIF and HEVC” from WWDC 2017 for more info.
availableVideoCodecTypes
? – Particularity