iOS 获取视频编码格式

+ (CMVideoCodecType)videoCodecTypeForURL:(NSURL *)url {
    AVURLAsset *videoAsset = (AVURLAsset *)[AVURLAsset URLAssetWithURL:url
                               options:nil];
    
    NSArray *videoAssetTracks = [videoAsset tracksWithMediaType:AVMediaTypeVideo];
    AVAssetTrack *videoAssetTrack = videoAssetTracks.firstObject;
    
    CMFormatDescriptionRef desc = (__bridge CMFormatDescriptionRef)videoAssetTrack.formatDescriptions.firstObject;
    CMVideoCodecType codec = CMVideoFormatDescriptionGetCodecType(desc);
    
    return codec;
}

你可能感兴趣的:(iOS 获取视频编码格式)