CMVideoFormatDescriptionGetCleanAperture() swift error
I can’t get the
CMVideoFormatDescriptionGetCleanAperture() function to work. Using
var videoDescriptionRef = port.formatDescription as CMVideoFormatDescriptionRef var cleanAperture = CMVideoFormatDescriptionGetCleanAperture(videoDescriptionRef, true)
var cleanAperture = CMVideoFormatDescriptionGetCleanAperture(port.formatDescription, true)
gives me the following errors, respectively:
Cannot convert expression's type 'CMVideoFormatDescriptionRef' to type 'CMVideoFormatDescriptionRef'
And the second is
Could not find an overlad for '__conversion' that accepts the supplied arguments
Does anyone know how to fix these or can anyone point out any errors in getting the format description for retrieving the clean aperture?
- AVCapture appendSampleBuffer
- Get all frames of Video IOS 6
- How do I convert a CGImage to CMSampleBufferRef?
- Maintaining good scroll performance when using AVPlayer
- Determine the corners of a sheet of paper with iOS 5 AV Foundation and core-image in realtime
- How to resume background audio in Swift 2 / AVPlayer?
2 Solutions Collect From Internet About “CMVideoFormatDescriptionGetCleanAperture() swift error”
CMFormatDescription itself does not have a member
takeUnretainedValue. It is a member of
Unmanaged<T>. You need to define an unmanaged variable first, get a value into it and then you retain it.
As I do not know how you created
port.formatDescription, here is an example where
formatDescription is created from PPS/SPS from an AVC video.
// create the receiving unmanaged variable var formatDescription: Unmanaged<CMVideoFormatDescription>? // call the not annotated method, this method will fill in formatDescription which is Unmanaged<T> let result = CMVideoFormatDescriptionCreateFromH264ParameterSets(nil, UInt(parameterSets.count), parameterSets, parameterSetSizes, 4, &formatDescription) // check result, yada yada yada before continuing // now we can actually retain the value let formatDescriptionRef = formatDescription!.takeUnretainedValue() as CMVideoFormatDescriptionRef // and we can do what ever we want with it in Swift without caring anymore. var cleanAperture = CMVideoFormatDescriptionGetCleanAperture(formatDescriptionRef, 1)
- Create an unmanaged type
- Use this unmanaged type in an not annotated method
- Retain the value
- Work with it without thinking about how you created it.
So adjust your code where you create the
port.formatDescription as a Unmanaged and you should be good.
Try to use .takeUnretainedValue() like this:
var videoDescription : CMVideoFormatDescription = port.formatDescription.takeUnretainedValue() var cleanAperture = CMVideoFormatDescriptionGetCleanAperture(videoDescription, true)
- finding out days remain from array of dates
- How to tint the background images of an UIButton programmatically and dynamically?
- What is the fastest/easiest way – step by step, from the beginning – to “code sign” my Qt app on OS X so that it can be distributed?
- How do I write universal swift code for both iOS and OS X. In cocoa I could use #ifdef, what do I do now?
- winSize] is wrong
- How to implement CollectionOf in Swift
- Xcode 4 NSLog Macro link in Xcode 3
- How can I detect yawn using Open CV
- Is a splash screen necessary for an iPhone app?
- Yet another “ld: symbol(s) not found for architecture x86_64” issue with boost, this time with mgiza
- Configure request method for a Siesta resource
- NSPredicate to test for NULL, and blank strings
- Gmail API: How to send attachments to the drafts on swift
- Perlin noise generator in Swift
- initWithNibName method in storyboard