Swift saving videos to cache folder without a size limit

Question

I have this code (Code below), and I am trying to save a 600mb video to the cache folder. I can successfully save a 59mb video to the folder, but when I try to save a big video, it just saves a file with 0kb. Is there a way to fix this? Code:

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 = outputURL
            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)
            })
        }
    }
}

Show source
| caching   | swift   | avassetexportsession   | avplayer   | nsfilemanager   2017-08-17 04:08 0 Answers

Answers to Swift saving videos to cache folder without a size limit ( 0 )

Leave a reply to - Swift saving videos to cache folder without a size limit

◀ Go back