簡體   English   中英

Swift:CMTimeRange 需要幫助(開始:結束:)

[英]Swift: Need Help for CMTimeRange(start: end:)

我對 CMTimeRange 有疑問。

嘗試設置 CMTimeRange 時出現警告。 將輸入 CMTimeRange 參數的 CMTimes 很好(如屏幕截圖所示)。 這段代碼有問題嗎?

底線是警告部分。

guard let exportSession = AVAssetExportSession(asset: asset, presetName: videoQualityString) else { return }
    exportSession.outputURL = resultingFileURL
    exportSession.outputFileType = .mp4
    
    // startTime, endTime => CMTime
    
    if let startTime = trimmerView.startTime, let endTime = trimmerView.endTime {
        print(startTime, endTime)
        print("efehowihfoweihfowiehfoihweofiehw")
        let timeRange = CMTimeRange(start: startTime, end: endTime)
        print("efehowihfoweihfowiehfoihweofiehw")
        exportSession.timeRange = timeRange
        exportSession.exportAsynchronously {
            switch exportSession.status {
            case .completed:
                completion(resultingFileURL)
                print("complete")
            case .failed:
                print("failed \(exportSession.error.debugDescription)")
            case .cancelled:
                print("cancelled \(exportSession.error.debugDescription)")
            default: break
            }
        }
    }

我錯過了文件擴展名。 (cutVideo -> cutVideo.mp4)

let resultingFilename = String(format: "%@_%@", ProcessInfo.processInfo.globallyUniqueString, "cutVideo.mp4")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM