var selectedPhotosArray = [UIImage]() var imageArrayToVideoURL = URL() imageArrayToVideoURL = NSURL(fileURLWithPath: NSHomeDirectory() + "/Documents/outputVideo.mp4") guard let videoWriter = try? AVAssetWriter(outputURL: imageArrayToVideoURL as URL, fileType: AVFileTypeMPEG4) else { fatalError("AVAssetWriter error") } let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] guard videoWriter.canApply(outputSettings: outputSettings, forMediaType: AVMediaTypeVideo) else { fatalError("Negative : Can't apply the Output settings...") } let videoWriterInput = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: outputSettings) let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] let pixelBufferAdaptor = AVAssetWriterInputPixelBufferAdaptor(assetWriterInput: videoWriterInput, sourcePixelBufferAttributes: sourcePixelBufferAttributesDictionary) if videoWriter.canAdd(videoWriterInput) { videoWriter.add(videoWriterInput) } if videoWriter.startWriting() { let zeroTime = CMTimeMake(Int64(1),Int32(1)) videoWriter.startSession(atSourceTime: zeroTime) let media_queue = DispatchQueue(label: "mediaInputQueue") videoWriterInput.requestMediaDataWhenReady(on: media_queue, using: { () -> Void in let fps: Int32 = 1 let framePerSecond: Int64 = Int64(1) let frameDuration = CMTimeMake(framePerSecond, fps) var frameCount: Int64 = 0 var appendSucceeded = true while (!selectedPhotosArray.isEmpty) { if (videoWriterInput.isReadyForMoreMediaData) { let lastFrameTime = CMTimeMake(frameCount * framePerSecond, fps) let presentationTime = frameCount == 0 ? lastFrameTime : CMTimeAdd(lastFrameTime, frameDuration) var pixelBuffer: CVPixelBuffer? = nil let status: CVReturn = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pixelBufferAdaptor.pixelBufferPool!, &pixelBuffer) if let pixelBuffer = pixelBuffer, status == 0 { let managedPixelBuffer = pixelBuffer CVPixelBufferLockBaseAddress(managedPixelBuffer, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0))) let data = CVPixelBufferGetBaseAddress(managedPixelBuffer) let rgbColorSpace = CGColorSpaceCreateDeviceRGB() let context = CGContext(data: data, width: Int(outputSize.width), height: Int(outputSize.height), bitsPerComponent: 8, bytesPerRow: CVPixelBufferGetBytesPerRow(managedPixelBuffer), space: rgbColorSpace, bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue) context!.clear(CGRect(x: 0, y: 0, width: CGFloat(outputSize.width), height: CGFloat(outputSize.height))) let horizontalRatio = CGFloat(outputSize.width) / nextPhoto.size.width let verticalRatio = CGFloat(outputSize.height) / nextPhoto.size.height //aspectRatio = max(horizontalRatio, verticalRatio) // ScaleAspectFill let aspectRatio = min(horizontalRatio, verticalRatio) // ScaleAspectFit let newSize: CGSize = CGSize(width: nextPhoto.size.width * aspectRatio, height: nextPhoto.size.height * aspectRatio) let x = newSize.width < outputSize.width ? (outputSize.width - newSize.width) / 2 : 0 let y = newSize.height < outputSize.height ? (outputSize.height - newSize.height) / 2 : 0 context?.draw(nextPhoto.cgImage!, in: CGRect(x: x, y: y, width: newSize.width, height: newSize.height)) CVPixelBufferUnlockBaseAddress(managedPixelBuffer, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0))) appendSucceeded = pixelBufferAdaptor.append(pixelBuffer, withPresentationTime: presentationTime) } else { print("Failed to allocate pixel buffer") appendSucceeded = false } } if !appendSucceeded { break } frameCount += 1 } videoWriterInput.markAsFinished() videoWriter.finishWriting { () -> Void in print(“complete”) } }) }
Standard input is empty
[1mprog.swift:1:30: [0;1;31merror: [0m[1muse of unresolved identifier 'UIImage' [0m var selectedPhotosArray = [UIImage]() [0;1;32m ^~~~~~~ [0m[1mprog.swift:3:30: [0;1;31merror: [0m[1muse of unresolved identifier 'URL' [0m var imageArrayToVideoURL = URL() [0;1;32m ^~~ [0m[1mprog.swift:5:32: [0;1;31merror: [0m[1muse of unresolved identifier 'NSURL' [0m imageArrayToVideoURL = NSURL(fileURLWithPath: NSHomeDirectory() + "/Documents/outputVideo.mp4") [0;1;32m ^~~~~ [0m[1mprog.swift:5:55: [0;1;31merror: [0m[1muse of unresolved identifier 'NSHomeDirectory' [0m imageArrayToVideoURL = NSURL(fileURLWithPath: NSHomeDirectory() + "/Documents/outputVideo.mp4") [0;1;32m ^~~~~~~~~~~~~~~ [0m[1mprog.swift:7:38: [0;1;31merror: [0m[1muse of unresolved identifier 'AVAssetWriter' [0m guard let videoWriter = try? AVAssetWriter(outputURL: imageArrayToVideoURL as URL, fileType: AVFileTypeMPEG4) else { [0;1;32m ^~~~~~~~~~~~~ [0m[1mprog.swift:7:102: [0;1;31merror: [0m[1muse of unresolved identifier 'AVFileTypeMPEG4' [0m guard let videoWriter = try? AVAssetWriter(outputURL: imageArrayToVideoURL as URL, fileType: AVFileTypeMPEG4) else { [0;1;32m ^~~~~~~~~~~~~~~ [0m[1mprog.swift:10:31: [0;1;31merror: [0m[1muse of unresolved identifier 'AVVideoCodecKey' [0m let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] [0;1;32m ^~~~~~~~~~~~~~~ [0m[1mprog.swift:10:49: [0;1;31merror: [0m[1muse of unresolved identifier 'AVVideoCodecH264' [0m let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] [0;1;32m ^~~~~~~~~~~~~~~~ [0m[1mprog.swift:10:67: [0;1;31merror: [0m[1muse of unresolved identifier 'AVVideoWidthKey' [0m let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] [0;1;32m ^~~~~~~~~~~~~~~ [0m[1mprog.swift:10:85: [0;1;31merror: [0m[1muse of unresolved identifier 'NSNumber' [0m let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] [0;1;32m ^~~~~~~~ [0m[1mprog.swift:10:107: [0;1;31merror: [0m[1muse of unresolved identifier 'outputSize' [0m let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] [0;1;32m ^~~~~~~~~~ [0m[1mprog.swift:10:127: [0;1;31merror: [0m[1muse of unresolved identifier 'AVVideoHeightKey' [0m let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] [0;1;32m ^~~~~~~~~~~~~~~~ [0m[1mprog.swift:10:146: [0;1;31merror: [0m[1muse of unresolved identifier 'NSNumber' [0m let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] [0;1;32m ^~~~~~~~ [0m[1mprog.swift:10:168: [0;1;31merror: [0m[1muse of unresolved identifier 'outputSize' [0m let outputSettings = [AVVideoCodecKey : AVVideoCodecH264, AVVideoWidthKey : NSNumber(value: Float(outputSize.width)), AVVideoHeightKey : NSNumber(value: Float(outputSize.height))] as [String : Any] [0;1;32m ^~~~~~~~~~ [0m[1mprog.swift:11:82: [0;1;31merror: [0m[1muse of unresolved identifier 'AVMediaTypeVideo' [0m guard videoWriter.canApply(outputSettings: outputSettings, forMediaType: AVMediaTypeVideo) else { [0;1;32m ^~~~~~~~~~~~~~~~ [0m[1mprog.swift:14:32: [0;1;31merror: [0m[1muse of unresolved identifier 'AVAssetWriterInput' [0m let videoWriterInput = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: outputSettings) [0;1;32m ^~~~~~~~~~~~~~~~~~ [0m[1mprog.swift:14:62: [0;1;31merror: [0m[1muse of unresolved identifier 'AVMediaTypeVideo' [0m let videoWriterInput = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: outputSettings) [0;1;32m ^~~~~~~~~~~~~~~~ [0m[1mprog.swift:15:54: [0;1;31merror: [0m[1muse of unresolved identifier 'kCVPixelBufferPixelFormatTypeKey' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0m[1mprog.swift:15:99: [0;1;31merror: [0m[1muse of unresolved identifier 'NSNumber' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~ [0m[1mprog.swift:15:115: [0;1;31merror: [0m[1muse of unresolved identifier 'kCVPixelFormatType_32ARGB' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~~~~~~~~~~~~~~~~~~ [0m[1mprog.swift:15:143: [0;1;31merror: [0m[1muse of unresolved identifier 'kCVPixelBufferWidthKey' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~~~~~~~~~~~~~~~ [0m[1mprog.swift:15:177: [0;1;31merror: [0m[1muse of unresolved identifier 'NSNumber' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~ [0m[1mprog.swift:15:199: [0;1;31merror: [0m[1muse of unresolved identifier 'outputSize' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~~~ [0m[1mprog.swift:15:219: [0;1;31merror: [0m[1muse of unresolved identifier 'kCVPixelBufferHeightKey' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~~~~~~~~~~~~~~~~ [0m[1mprog.swift:15:254: [0;1;31merror: [0m[1muse of unresolved identifier 'NSNumber' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~ [0m[1mprog.swift:15:276: [0;1;31merror: [0m[1muse of unresolved identifier 'outputSize' [0m let sourcePixelBufferAttributesDictionary = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(value: kCVPixelFormatType_32ARGB), kCVPixelBufferWidthKey as String: NSNumber(value: Float(outputSize.width)), kCVPixelBufferHeightKey as String: NSNumber(value: Float(outputSize.height))] [0;1;32m ^~~~~~~~~~ [0m[1mprog.swift:16:34: [0;1;31merror: [0m[1muse of unresolved identifier 'AVAssetWriterInputPixelBufferAdaptor' [0m let pixelBufferAdaptor = AVAssetWriterInputPixelBufferAdaptor(assetWriterInput: videoWriterInput, sourcePixelBufferAttributes: sourcePixelBufferAttributesDictionary) [0;1;32m ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0m[1mprog.swift:68:38: [0;1;31merror: [0m[1municode curly quote found, replace with '"' [0m print(“complete”) [1mprog.swift:68:27: [0;1;31merror: [0m[1municode curly quote found, replace with '"' [0m print(“complete”) [1mprog.swift:21:28: [0;1;31merror: [0m[1muse of unresolved identifier 'CMTimeMake' [0m let zeroTime = CMTimeMake(Int64(1),Int32(1)) [0;1;32m ^~~~~~~~~~ [0m[1mprog.swift:25:31: [0;1;31merror: [0m[1muse of unresolved identifier 'DispatchQueue' [0m let media_queue = DispatchQueue(label: "mediaInputQueue") [0;1;32m ^~~~~~~~~~~~~ [0m<unknown>:0: error: error opening input file 'prog.o' (No such file or directory ) clang: error: no such file or directory: 'prog.o' clang: error: no such file or directory: '@prog.autolink'
Standard output is empty