release pooled memory while extracting frames
This commit is contained in:
1 parent
7bf227a6de
commit
bfaf9d1678
1 file changed
+12
-10
@@ -140,17 +140,19 @@ class VideoHandler {
|
||||
|
||||
while let sampleBuffer = readerOutput.copyNextSampleBuffer(),
|
||||
let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) {
|
||||
let name = "\(frameCount).jpg"
|
||||
let filePathName = "assets/\(name)"
|
||||
UIApplication.shared.change(title: NSLocalizedString("Generating Video...", comment: ""), body: String(format: NSLocalizedString("Creating %@...", comment: "the message for the current image that is being generated"), filePathName))
|
||||
try? autoreleasepool {
|
||||
let name = "\(frameCount).jpg"
|
||||
let filePathName = "assets/\(name)"
|
||||
UIApplication.shared.change(title: NSLocalizedString("Generating Video...", comment: ""), body: String(format: NSLocalizedString("Creating %@...", comment: "the message for the current image that is being generated"), filePathName))
|
||||
|
||||
let ciImage = CIImage(cvPixelBuffer: imageBuffer)
|
||||
let context = CIContext()
|
||||
if let cgImage = context.createCGImage(ciImage, from: ciImage.extent) {
|
||||
if let img = cgImage.jpg {
|
||||
try img.write(to: assetsFolder.appendingPathComponent(name))
|
||||
camlData += "\t\t\t<CGImage src=\"assets/\(name)\"/>\n"
|
||||
frameCount += 1
|
||||
let ciImage = CIImage(cvPixelBuffer: imageBuffer)
|
||||
let context = CIContext()
|
||||
if let cgImage = context.createCGImage(ciImage, from: ciImage.extent) {
|
||||
if let img = cgImage.jpg {
|
||||
try img.write(to: assetsFolder.appendingPathComponent(name))
|
||||
camlData += "\t\t\t<CGImage src=\"assets/\(name)\"/>\n"
|
||||
frameCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user