Open CricHeroesiOS opened 3 years ago
I'm also seeing this same crash, using default implementation as recommend from README.
+1
Thank you for opening this issue. I will look into it and fix it in a couple of days.
+1 same issue
Could you please let me know what is the scenario that leads to this issue? I understand what the problem is, but surprised that it happens and I can't produce it. Any details could help me fix it. Thank you. @kientrung0412 @nmohamedtharik @pouty18
+1 Same issue
Crash at this line : let sampleBuffer:CMSampleBuffer? = audioReaderOutput.copyNextSampleBuffer()
@AbedElazizShe it's not crash if i using your example, only crash if use the LightCompressor.swift in the library.it's crash on the same line as @DixPatel009 mention above
Thank you @DixPatel009 and @kientrung0412. This is a great information and sorry it is happening to you. I will work on fixing that tomorrow. I will notify you when that is done. Cheers.
@AbedElazizShe any updates on crash fix?
@AbedElazizShe any updates on crash ?
@ghimireprashant @BasavarajIOS Could you please try to update to the latest version? 0.1.8. I can't produce the issue at all, so the fix is not tested.
If it is still not working, please provide me a sample code where the issue happens. Thank you.
@AbedElazizShe i tried on latest version. Just try to compress multiple video at once you will get that error. for refence: let destination = [videoToCompress, videoToCompress, videoToCompress, videoToCompress] for item in destination { let startingPoint = Date() let videoCompressor = LightCompressor()
compression = videoCompressor.compressVideo(source: item,
destination: destinationPath as URL,
quality: .medium,
isMinBitRateEnabled: true,
keepOriginalResolution: false,
progressQueue: .main,
progressHandler: { progress in
DispatchQueue.main.async { [unowned self] in
self.progressBar.progress = Float(progress.fractionCompleted)
self.progressLabel.text = "\(String(format: "%.0f", progress.fractionCompleted * 100))%"
}},
completion: {[weak self] result in
guard let `self` = self else { return }
switch result {
case .onSuccess(let path):
self.compressedPath = path
DispatchQueue.main.async { [unowned self] in
self.sizeAfterCompression.isHidden = false
self.duration.isHidden = false
self.progressBar.isHidden = true
self.progressLabel.isHidden = true
self.sizeAfterCompression.text = "Size after compression: \(path.fileSizeInMB())"
self.duration.text = "Duration: \(String(format: "%.2f", startingPoint.timeIntervalSinceNow * -1)) seconds"
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: path)
})
}
case .onStart:
self.progressBar.isHidden = false
self.progressLabel.isHidden = false
self.sizeAfterCompression.isHidden = true
self.duration.isHidden = true
//self.originalSize.visiblity(gone: false)
case .onFailure(let error):
self.progressBar.isHidden = true
self.progressLabel.isHidden = false
self.progressLabel.text = (error as! CompressionError).title
case .onCancelled:
print("---------------------------")
print("Cancelled")
print("---------------------------")
}
})
}
Thank you. :)
I still get that error with 0.1.8. Funny thing, it doesn't happen in the demo app, even when calling the library with the same parameters and using the same video 🤔
Ok, my version was crashing because I was saving the final destination in the same folder as the "tmp" file I got from the Media Library, I was doing something like this:
let finalURL = url.deletingLastPathComponent().appendingPathComponent("compressed.mp4")
Probably that folder gets deleted while compressing and the whole thing breaks, it started working after I changed my code to save the destination in a proper tmp folder like in the sample:
let destinationPath = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("compressed.mp4")
try? FileManager.default.removeItem(at: destinationPath)
+1, Multiple video leads to
Thank you for all the information and sorry for the late reply. Knowing the scenario will make it easier to fix, will test multiple video selection and try to fix the issue as soon as possible.
I had this problem too, but once I set my destination path to
let destination = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("\(UUID().uuidString).mp4")
it works totally fine with either single or when looping over videos. When I download the app container, they're all in the tmp directory, compressed af 👍
I realized this crash but this was my fault. outputURL that given to AVAssetWriter was not existing directory. Fixed when set existing folder or temporaryFolder. ℹ️
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[AVAssetReader startReading] cannot be called again after reading has already started'