So I used this code:
func videoSnapshot(filePathLocal: String) -> UIImage? {
let vidURL = NSURL(fileURLWithPath:filePathLocal as String)
let asset = AVURLAsset(URL: vidURL)
let generator = AVAssetImageGenerator(asset: asset)
generator.appliesPreferredTrackTransform = true
let timestamp = CMTime(seconds: 1, preferredTimescale: 60)
do {
let imageRef = try generator.copyCGImageAtTime(timestamp, actualTime: nil)
return UIImage(CGImage: imageRef)
}
catch
{
print("Image generation failed with error \(error)")
return nil
}
}
to get the UIImage
of a snapshot from my video. I called this function like this:
let tempImg: UIImage = videoSnapshot(pathToFile)!
now I would like to upload this tempImg to my server, and to to this I need a path to this file - I will pass it later to the function that uploads data further. How can I get a temporary path to it and store it as a String
or NSURL
?