-1
我需要幫助在swift 2中製作CMTime變量,以便我可以創建AVMutableCompostion。當前代碼:如何使用NSTimeInterval製作CMTime參考
let videoAsset: AnyObject! = AVAsset(URL: outputFileURL)
let videoDuration:CMTime = CMTimeMake(Int64(videoAsset.duration), 1)
但上面的變量videoDuration保持返回零!我仔細檢查,以確保videoAsset.duration不是零,也不是。
摘要:導致它在其中「videoDuration」中傳遞的peramiter
// Merge audio and video tracks to complete video
let videoTrack = mixComposition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: Int32(kCMPersistentTrackID_Invalid))
do {
try videoTrack.insertTimeRange(CMTimeRangeMake(kCMTimeZero, videoDuration),
ofTrack: videoAsset.tracksWithMediaType(AVMediaTypeVideo)[0] ,
atTime: kCMTimeZero)
} catch _ {
/* TODO: Finish migration: handle the expression passed to error arg: kCMTimeZero */
}
請幫線在這裏崩潰!任何建議將不勝感激:)
它在Swift 2.0之前工作正常?唯一給我一個問題的是CMTime參數 –