NextLevel / NextLevelSessionExporter

🔄 Export and transcode media in Swift
http://nextlevel.engineering
MIT License
262 stars 48 forks source link

RenderHandler not called when exporting #19

Closed alexjameslittle closed 4 years ago

alexjameslittle commented 5 years ago

I'm trying to use the export method with the render handler in order to manipulate the output buffers with affects and filters however the handler never gets called.

       do {
            try exporter.export(renderHandler: { input, time, output in
                let image = MTIImage(cvPixelBuffer: input, alphaType: .alphaIsOne)
                let outputImage = MetalFilterProcessor.shared.applyFilters(for: clip.metaData, input: image, currentTime: time)

                do {
                    try context.render(outputImage, to: output)
                } catch {
                    print("Error applying filters")
                }

            }, progressHandler: { progress in
                print(progress)
            }) { status in
                switch status {
                case .completed:
                    print("video export completed")
                    break
                case .cancelled:
                    print("video export cancelled")
                    break
                default:
                    break
                }
            }
        } catch {
            print("failed to export")
        }
alexjameslittle commented 5 years ago

This is due to the result of the following line to always be kCVReturnInvalidPixelFormat

let result = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pixelBufferPool, &toRenderBuffer)
Monkey-X-Byte commented 4 years ago

pixelBufferAttrib[kCVPixelBufferPixelFormatTypeKey as String] = NSNumber(integerLiteral: Int(kCVPixelFormatType_32BGRA))

piemonte commented 4 years ago

thanks @alexjameslittle will put in a fix

piemonte commented 4 years ago

@alexjameslittle hope that helps, let me know if it addresses your issues and i can publish a release

alexjameslittle commented 4 years ago

Sorry man, I'm no longer working on this project!