微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决斯威夫特: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")

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。