0

I have a problem with CMTimeRange.

Warning occurs when attempting to set CMTimeRange. The CMTimes that will enter the parameters of CMTimeRange are fine (as shown in the screenshot). 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
            }
        }
    }

1 Answers1

0

I missed file extension! (cutVideo -> cutVideo.mp4)

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