我想将存储在AVPlayerItem中的.mp4-video导出到文件系统.如果成功,我想把它变成一个NSData变量(但这不是问题的一部分,只是想告诉你为什么我想把它存储到文件系统中).
//This is the AVPlayerItem-Object
let item = self.talentView.getCurrentItem()
//They return all true, so the item itself is not the issue
print(item.asset.isPlayable)
print(item.asset.isReadable)
print(item.asset.isExportable)
//Creating Path, where the file will be stored, also tried "video.mp4" at the appending string
var exportPath: NSString = NSTemporaryDirectory().appendingFormat("/video.mp4")
var exportUrl: NSURL = NSURL.fileURL(withPath: exportPath as String) as NSURL
let session = AVAssetExportSession(asset: item.asset, presetName: AVAssetExportPresetPassthrough)
session?.outputFileType = AVFileTypeMPEG4
session?.outputURL = exportUrl as URL
session?.exportAsynchronously(completionHandler: {
//case is always .failed
switch session!.status {
case .failed: …Run Code Online (Sandbox Code Playgroud)