VideoToolbox does not create an encoder session for mpeg4 in Swift 3.0
Asked Answered
M

0

1

I`ve catch a problem to create a compression session for the MPEG4 encoder with VideoToolbox after migration on Swift 3.0. Before the migration it worked fine.

Here is my upgraded code:

    let imageAttributes:[NSString: AnyObject] = [
            kCVPixelBufferPixelFormatTypeKey: Int(colorScheme) as AnyObject,
            kCVPixelBufferIOSurfacePropertiesKey: [:] as AnyObject,
            kCVPixelBufferOpenGLESCompatibilityKey: true as AnyObject,
            kCVPixelBufferWidthKey: outputWidth as AnyObject,
            kCVPixelBufferHeightKey: outputHeight as AnyObject,
            ]

     let imgeAttributesDictionary: CFDictionary = imageAttributes as CFDictionary

     let encoderType = kCMVideoCodecType_MPEG4Video


     var status = VTCompressionSessionCreate(kCFAllocatorDefault, Int32(outputWidth), Int32(outputHeight), encoderType, nil, imgeAttributesDictionary, nil, { (outputCallbackRefCon: UnsafeMutableRawPointer?, sourceFrameRefCon: UnsafeMutableRawPointer?, status: OSStatus, infoFlags: VTEncodeInfoFlags, sampleBuffer: CMSampleBuffer?) -> Void in

                VideoEncoder.compressionCallback(outputCallbackRefCon: outputCallbackRefCon, sourceFrameRefCon: sourceFrameRefCon, status: status, infoFlags: infoFlags, sampleBuffer: sampleBuffer)

        }, nil, &session)

And every time I receive status error -12908 (kVTCouldNotFindVideoEncoderErr). The interesting point is that the same configuration but with

 let encoderType = kCMVideoCodecType_H264

is working perfect.

Does anybody know what happening here?

This is my related question about updating code for the encoder configuration upto Swift 3.0

Musclebound answered 11/10, 2016 at 21:53 Comment(1)
I met the same problem with MJPEG, don't why it doesn't existDash

© 2022 - 2024 — McMap. All rights reserved.