IOS AVPlayer get fps

user346443 picture user346443 · May 19, 2012 · Viewed 9.9k times · Source

Im trying to figure out how to retrieve a videos frame rate via AVPlayer. AVPlayerItem has a rate variable but it only returns a value between 0 and 2 (usually 1 when playing). Anybody have an idea how to get the video frame rate?

Cheers

Answer

Paresh Navadiya picture Paresh Navadiya · Apr 20, 2013

Use AVAssetTrack's nominalFrameRate property.

Below method to get FrameRate : Here queuePlayer is AVPlayer

-(float)getFrameRateFromAVPlayer
{
  float fps=0.00;
  if (self.queuePlayer.currentItem.asset) {
    AVAssetTrack * videoATrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] lastObject];
    if(videoATrack)
    {
        fps = videoATrack.nominalFrameRate;
    }
  }
  return fps;
}