VideoToolbox does not create coding session for mpeg4 in Swift 3.0

I have a problem creating a compression session for an MPEG4 encoder using VideoToolbox after migrating to Swift 3.0. Before migration, it worked fine.

Here is my updated 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 get a status error -12908 (kVTCouldNotFindVideoEncoderErr) . An interesting point is that the same configuration, but with

  let encoderType = kCMVideoCodecType_H264 

works perfect.

Does anyone know what is going on here?

This is my related question about updating the code to configure the encoder to Swift 3.0

+1
source share

Source: https://habr.com/ru/post/1257989/


All Articles