【问题标题】:Swift: Need Help for CMTimeRange(start: end:)Swift:CMTimeRange 需要帮助(开始:结束 :)
【发布时间】:2021-06-09 14:37:47
【问题描述】:

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

【问题讨论】:

    标签: swift video export cmtime


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-02
      • 2014-08-27
      • 1970-01-01
      • 1970-01-01
      • 2023-02-19
      • 1970-01-01
      • 1970-01-01
      • 2019-07-15
      相关资源
      最近更新 更多