我的AVAssetWriter的完成处理程序在完成写入后创建一个导出器,以便视频可以在播放器中显示,以便用户可以根据需要保存它。这一切都很好,但我想改变书面视频,并在完成写作后简单地旋转。
我发现的答案不同于旋转视频,因为它录制或弃用旧的Objective-C方式,不再适用。
我的完成处理程序和导出程序看起来像这样。导出器知道outputFileType,所以我认为我可以在那里旋转视频:
assetWriter?.finishWriting(completionHandler: {[unowned self] () -> Void in
let firstAsset = AVURLAsset(url: self.movieURL() as URL)
guard let exporter = AVAssetExportSession(asset: firstAsset, presetName: AVAssetExportPresetHighestQuality) else { return }
exporter.outputURL = self.movieURL() as URL
exporter.outputFileType = AVFileType.mov
exporter.exportAsynchronously() {
DispatchQueue.main.async(){
// below here is where another class is presented with the
// video URL to display in a player with the option to save