In my iOS app (SDK 5.6), I create an AVURLAsset from a short video, like so:
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:assetURL options:nil];
This seems to work fine. If I examine the asset in gdb, it looks like this:
(gdb) po asset
<AVURLAsset: 0x1a1c40, URL = file://localhost/var/mobile/Applications/A2142D8E-BC19-4E0B-A4C8-ABED4F7D4970/Documents/sample_iTunes.mov>
I use a sample .mov file from the Apple website, stored in the app’s Documents directory.
I would like to know the duration of this video, for further processing, but when I examine the duration property, I get this:
(gdb) po asset.duration
There is no member named duration.
What am I doing wrong? Is there any other way to determine the duration of an AVAsset or AVAssetTrack?
TIA: John
Creating the asset, however, does not necessarily mean that it’s ready for use. To be used, an asset must have loaded its tracks. Load the asset with
And there should be a ‘duration’ key in the array.
When loading completes, get the duration with