错误:此媒体不支持该操作 - Swift

Fra*_*gat 5 nsfilemanager avassetexportsession avasset swift

我正在尝试在 Apple TV 上使用以下代码保存视频:

func playerItemDidReachEnd(_ notification: Notification) {

    if notification.object as? AVPlayerItem  == player.currentItem {
        player.seek(to: kCMTimeZero)
        let exporter = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHighestQuality)
        let filename = "video.mp4"
        let documentsDirectory = FileManager.default.urls(for: FileManager.SearchPathDirectory.documentDirectory, in: FileManager.SearchPathDomainMask.userDomainMask).last!

        let outputURL = documentsDirectory.appendingPathComponent(filename)
        exporter?.outputURL = NSURL.fileURL(withPath: outputURL.path)
        exporter?.outputFileType = AVFileTypeMPEG4
        let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
        let url = NSURL(fileURLWithPath: path)
        let filePath = url.appendingPathComponent(filename)?.path
        let fileManager = FileManager.default

        if fileManager.fileExists(atPath: filePath!) {

        } else {
            exporter?.exportAsynchronously(completionHandler: {

                print(exporter?.status.rawValue)
                print(exporter?.error)
            })
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我也使用它作为资产并且不想更改资产:

lazy var asset: AVURLAsset = {

         var asset: AVURLAsset = AVURLAsset(url: self.url)

         asset.resourceLoader.setDelegate(self as? AVAssetResourceLoaderDelegate, queue: DispatchQueue.main)

         return asset
         }()
Run Code Online (Sandbox Code Playgroud)

但我收到这个错误。这是什么意思,我该如何解决?谢谢 :)

Optional(Error Domain=AVFoundationErrorDomain Code=-11838 "Operation Stopped" UserInfo={NSUnderlyingError=0x608000443300 {Error Domain=NSOSStatusErrorDomain Code=-12109 "(null)"}, NSLocalizedFailureReason=The operation is not supported for this media., NSLocalizedDescription=Operation Stopped})