简体   繁体   English

Swift:CMTimeRange 需要帮助(开始:结束:)

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

I have a problem with CMTimeRange.我对 CMTimeRange 有疑问。

Warning occurs when attempting to set CMTimeRange.尝试设置 CMTimeRange 时出现警告。 The CMTimes that will enter the parameters of CMTimeRange are fine (as shown in the screenshot).将输入 CMTimeRange 参数的 CMTimes 很好(如屏幕截图所示)。 Is there a problem with this code?这段代码有问题吗?

The bottom line is the warning part.底线是警告部分。

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
            }
        }
    }

I missed file extension.我错过了文件扩展名。 (cutVideo -> cutVideo.mp4) (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