Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get number of frames in a video via AVFoundation

I'm trying to find the number of frames in a video I've just opened, without decoding all the frames.

I open with AVAsset and then get an AVAssetTrack for the video. What next ?

like image 590
koan Avatar asked Nov 30 '12 12:11

koan


1 Answers

You could do this:

float durationInSeconds = CMTimeGetSeconds(asset.duration);
float framesPerSecond = assetTrack.nominalFrameRate;
float numberOfFrames = durationInSeconds * framesPerSecond;
like image 167
yairsz Avatar answered Oct 05 '22 22:10

yairsz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!