Equivalent Casting of JPEG to Data, but with .mov files in Swift

47 Views Asked by At

I have some code that works fine, using Amplify to push and pull images from an AWS-S3 bucket.

let uploadTask = Amplify.Storage.uploadData(key: imageKey, data: srcData, options: nil)
        Task {
            for await progress in await uploadTask.progress {
                print("Progress: \(progress)")
            }
        }
        do {
            let value = try await uploadTask.value
            print("Completed: \(value)")
            return true
        } catch {
            print("problem uploading \(error)")
        }
        return false

This is fine for the upload, and there's corresponding code working for the download.

But my goal is to move .mov files up to AWS from inside an app, and to retrieve them, also from the app. I think what I've got will work, but the missing piece is how to

  • convert the .mov file (or other Mac compatible movie format) to data for upload
  • convert the retrieved data back to a .mov file for cacheing or playing (not streaming).

The movies are small (<15Mb) so holding them in memory won't be a problem, since a maximum of 10 would be available to play at one time, in case that matters. But they will be saved to the Caches Directory.

I assume this is either an AVAsset or an AVURLAsset, but I haven't understood what the process that would be the equivalent of <UIImage>.jpegData(etc.…) but for timebases media is.

0

There are 0 best solutions below