Creating thumbnail from local video in swift

前端 未结 7 2227
挽巷
挽巷 2020-12-04 06:59

How to create thumbnail in swift from a local video file ?

For example if the video file path is located here :

file:///Users/Dev/Library/Developer/Co

7条回答
  •  眼角桃花
    2020-12-04 07:37

    func saveImageDocumentDirectoryWithDate(tempImage:UIImage, block : @escaping (_ url: URL?) -> Void ){
    
        let documentsDirectoryURL = try! FileManager().url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
    
        let random : String =  randomString(length: 5)
    
        let fileURL = documentsDirectoryURL.appendingPathComponent(String(format:"CPImage%@.png",random))
        do { try tempImage.pngData()?.write(to: fileURL) }
        catch { block(nil) }
        block(fileURL)}
    

提交回复
热议问题