Created
January 28, 2022 13:07
-
-
Save doozMen/1f60e0920d40afd71f4ff761c2a19253 to your computer and use it in GitHub Desktop.
Creates a SMSampleBuffer for video to be used in unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createEmptyVideo() -> CMSampleBuffer { | |
var pixelBuffer : CVPixelBuffer? = nil | |
CVPixelBufferCreate(kCFAllocatorDefault, 100, 100, kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange, nil, &pixelBuffer) | |
var info = CMSampleTimingInfo() | |
info.presentationTimeStamp = .zero | |
info.duration = .invalid | |
info.decodeTimeStamp = .invalid | |
var formatDesc: CMFormatDescription? = nil | |
CMVideoFormatDescriptionCreateForImageBuffer(allocator: kCFAllocatorDefault, imageBuffer: pixelBuffer!, formatDescriptionOut: &formatDesc) | |
var sampleBuffer: CMSampleBuffer? = nil | |
CMSampleBufferCreateReadyWithImageBuffer( | |
allocator: kCFAllocatorDefault, | |
imageBuffer: pixelBuffer!, | |
formatDescription: formatDesc!, | |
sampleTiming: &info, | |
sampleBufferOut: &sampleBuffer | |
) | |
return sampleBuffer! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment