Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim video issue. #40

Open
DGP13 opened this issue Oct 23, 2018 · 2 comments
Open

Trim video issue. #40

DGP13 opened this issue Oct 23, 2018 · 2 comments

Comments

@DGP13
Copy link

DGP13 commented Oct 23, 2018

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.

@HHK1
Copy link
Owner

HHK1 commented Oct 23, 2018

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

@DGP13
Copy link
Author

DGP13 commented Oct 24, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants