斯威夫特:CMTimeRange 需要帮助开始:结束:

问题描述

我的 CMTimeRange 有问题。

尝试设置 CMTimeRange 时出现警告。 将进入 CMTimeRange 参数的 CMTimes 很好(如屏幕截图所示)。 这段代码有问题吗?

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

解决方法

我错过了文件扩展名! (cutVideo -> cutVideo.mp4)

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...