randomor randomor - 4 months ago 51
C Question

Converting CMTime to human readable time in objective-c

So I have a CMTime from a video. How do I convert it into a nice string like in the video time duration label in the Photo App. Is there some convenience methods that handle this? Thanks.

AVURLAsset* videoAsset = [AVURLAsset URLAssetWithURL:url options:nil];
CMTime videoDuration = videoAsset.duration;
float videoDurationSeconds = CMTimeGetSeconds(videoDuration);


For example you can use NSDate and it's description method. You can specify any output format you want.