randomor randomor - 19 days ago 8
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);

Answer

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

Comments