PryntTrimmerView icon indicating copy to clipboard operation
PryntTrimmerView copied to clipboard

Trim video issue.

Open DGP13 opened this issue 6 years ago • 2 comments

I'm trim video using this PryntTrimmerView lib. I have set min 15 second & max 60 second but save video total duration is 52 second.

DGP13 avatar Oct 23 '18 09:10 DGP13

Can you provide an example (video asset included) to reproduce please ? What was the duration of the original asset ?

HHK1 avatar Oct 23 '18 11:10 HHK1

This is export trim video code....

do { let asset = AVURLAsset(url: asset_url) let trimmedAsset = try asset .assetByTrimming(startTime: trimmerView.startTime ?? kCMTimeZero, endTime: trimmerView.endTime ?? url_AVURLAsset.duration)

        let destinationURL = URL(fileURLWithPath: NSTemporaryDirectory())
            .appendingUniquePathComponent(pathExtension: "mov")
        
        print(destinationURL)
        
        try trimmedAsset.export(to: destinationURL) { [weak self] in
            //guard let strongSelf = self else { return }
            
            print("save \(destinationURL)")
            DispatchQueue.global(qos: .background).async {
                
                let data = NSData(contentsOf: destinationURL)
                print("File size before compression: \(Double((data?.length)! / 1048576)) mb")
                self?.compressVideoOutput(videoURL: destinationURL)
                
            }
            
        }
    } catch let error {
        print("💩 \(error)")
    }

I'm set max 1 minit video allow otherwise is automatically trim.

DGP13 avatar Oct 24 '18 05:10 DGP13