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(),
|
while let sampleBuffer = readerOutput.copyNextSampleBuffer(),
|
||||||
let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) {
|
let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) {
|
||||||
let name = "\(frameCount).jpg"
|
try? autoreleasepool {
|
||||||
let filePathName = "assets/\(name)"
|
let name = "\(frameCount).jpg"
|
||||||
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 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 ciImage = CIImage(cvPixelBuffer: imageBuffer)
|
||||||
let context = CIContext()
|
let context = CIContext()
|
||||||
if let cgImage = context.createCGImage(ciImage, from: ciImage.extent) {
|
if let cgImage = context.createCGImage(ciImage, from: ciImage.extent) {
|
||||||
if let img = cgImage.jpg {
|
if let img = cgImage.jpg {
|
||||||
try img.write(to: assetsFolder.appendingPathComponent(name))
|
try img.write(to: assetsFolder.appendingPathComponent(name))
|
||||||
camlData += "\t\t\t<CGImage src=\"assets/\(name)\"/>\n"
|
camlData += "\t\t\t<CGImage src=\"assets/\(name)\"/>\n"
|
||||||
frameCount += 1
|
frameCount += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user