I want to get the frame rate for a specific video. I tried to look at APIs in the AVFoundation
and AssetsLibrary
like AVURLAsset or AVAssetReader. None of them are really helpful. Does anybody know a method in the Apple's frameworks/library to get the frame rate
The easier option is to obtain an AVAssetTrack and read its nominalFrameRate property. Looks like this can help you.
Nominal frame rate is the frame rate of the track, in frames per second. (read-only) AVAssetTrack Class @property(nonatomic, readonly) float nominalFrameRate
For iOS 7+ you can use the currentVideoFrameRate property of AVPlayerItemTrack. Its the only consistent property that I've seen measure FPS. The nominalFrameRate property seems to be broken in HLS streams.
AVPlayerItem *item = AVPlayer.currentItem; // Your current item
float fps = 0.00;
for (AVPlayerItemTrack *track in item.tracks) {
if ([track.assetTrack.mediaType isEqualToString:AVMediaTypeVideo]) {
fps = track.currentVideoFrameRate;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With