[英]Creating a time range for AVAssetExportSession
我想知道如何从时间戳AVAssetExportSession
的时间范围,例如:
NSTimeInterval start = [[NSDate date] timeIntervalSince1970];
NSTimeInterval end = [[NSDate date] timeIntervalSince1970];
我用于导出会话的代码如下:
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
exportSession.outputURL = videoURL;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
exportSession.timeRange = CMTimeRangeFromTimeToTime(start, end);
谢谢你的帮助!
该物业timeRange
在AVAssetExportSession
允许你做一个资产指定的部分出口从哪里开始和持续时间。 如果没有指定它将导出整个视频,换句话说,它将从零开始并将导出总持续时间。
开始和持续时间都应表示为CMTime
。
例如,如果要导出资产的前半部分:
CMTime half = CMTimeMultiplyByFloat64(exportSession.asset.duration, 0.5);
exportSession.timeRange = CMTimeRangeMake(kCMTimeZero, half);
或下半场:
exportSession.timeRange = CMTimeRangeMake(half, half);
或者最后10秒:
CMTime _10 = CMTimeMakeWithSeconds(10, 600);
CMTime tMinus10 = CMTimeSubtract(exportSession.asset.duration, _10);
exportSession.timeRange = CMTimeRangeMake(tMinus10, _10);
检查CMTime
参考以获取计算所需精确时间的其他方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.