iOS 获取视频编码格式

2019-11-11  本文已影响0人  欢乐的乐
+ (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;
}
上一篇下一篇

猜你喜欢

热点阅读