[英]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.