Getting duration of video taken by camera iphone s

2019-08-24 01:45发布

问题:

I am trying to get the duration of a video taken with the camera using UIImagePickerController on the iphone, has anyone found a solution to this?

Thanks

Daniel

回答1:

You can now do this using AVFoundation you can make your movie into an AVAsset and then check the duration property



回答2:

Oh, why, hello hopelessly obsolete answer. I'm afraid you're only left here as historical evidence that yes, before iOS 4 if you wanted to do anything remotely interesting on a recorded video (besides playing it) you had to implement the processing yourself.

I don't know of any framework function to do so, so I'm afraid you'll have to parse the video container yourself (which by the way, is QuickTime/.mov) to extract this info. It's not like it's not documented. Luckily since the provider is known, you can trust all info to be truthful, which you can't assume of random videos found on the web.