如何在iOS SDK中获取视频的FPS。我试过下面的代码行,但对我来说似乎并不完美。
AVAssetTrack *videoAssetTrack = [myAsset tracksWithMediaType:AVMediaTypeVideo].firstObject;
NSLog(@"FPS is : %f ",videoAssetTrack.nominalFrameRate);
任何帮助将不胜感激。
答案 0 :(得分:4)
我在下面的代码行中得到了正确的FPS:
AVAsset * myAsset = [[AVURLAsset alloc] initWithURL: _videoUrl options: nil];
AVAssetTrack * videoAssetTrack = [myAsset tracksWithMediaType: AVMediaTypeVideo].firstObject;
NSLog(@"FPS is : %f ", videoAssetTrack.nominalFrameRate);
答案 1 :(得分:2)
extension AVAsset {
/**
* Get FPS from AVAsset
*/
var fps: Float? {
self.tracks(withMediaType: .video).first?.nominalFrameRate
}
}