import VideoToolbox
import AVFoundation
// Function to check hardware decode support for a given codec
func checkHardwareDecodeSupport() {
// List of codec types to check (based on M4 Max Media Engine + VP9)
let codecTypes: [CMVideoCodecType] = [
kCMVideoCodecType_H264,
kCMVideoCodecType_HEVC,
kCMVideoCodecType_AppleProRes422,
kCMVideoCodecType_AppleProResRAW,
kCMVideoCodecType_AV1,
kCMVideoCodecType_VP9 // Added VP9
]
// Dictionary to map codec types to human-readable names
let codecNames: [CMVideoCodecType: String] = [
kCMVideoCodecType_H264: "H.264",
kCMVideoCodecType_HEVC: "HEVC (H.265)",
kCMVideoCodecType_AppleProRes422: "ProRes 422",
kCMVideoCodecType_AppleProResRAW: "ProRes RAW",
kCMVideoCodecType_AV1: "AV1",
kCMVideoCodecType_VP9: "VP9"
]
VTRegisterSupplementalVideoDecoderIfAvailable(kCMVideoCodecType_VP9)
print("Checking Hardware Decode Capabilities on Mac...\n")
for codec in codecTypes {
guard let codecName = codecNames[codec] else { continue }
// Check if hardware decode is supported
let isHardwareSupported = VTIsHardwareDecodeSupported(codec)
print("Codec: \(codecName)")
print("Hardware Decode Supported: \(isHardwareSupported ? "Yes" : "No")")
print("---")
}
}
// Run the check
checkHardwareDecodeSupport()