* perf: Automatically determine Pixel Format depending on active format. (More efficient video recording 🚀)
* perf: Skip `AVAssetWriter` transform by directly correctly orienting the Video Output connection
* feat: Support camera flipping while recording
* feat: Run frame processor on separate queue, avoids stutters in video recordigns
* feat: Automatically drop late frame processor frames
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
| //
 | |
| //  AVAssetWriterInputPixelBufferAdaptor+initWithVideoSettings.swift
 | |
| //  VisionCamera
 | |
| //
 | |
| //  Created by Marc Rousavy on 05.05.21.
 | |
| //  Copyright © 2021 mrousavy. All rights reserved.
 | |
| //
 | |
| 
 | |
| import AVFoundation
 | |
| import Foundation
 | |
| 
 | |
| extension AVAssetWriterInputPixelBufferAdaptor {
 | |
|   /**
 | |
|    Convenience initializer to extract correct attributes from the given videoSettings.
 | |
|    */
 | |
|   convenience init(assetWriterInput: AVAssetWriterInput,
 | |
|                    withVideoSettings videoSettings: [String: Any],
 | |
|                    pixelFormat: OSType) {
 | |
|     var attributes: [String: Any] = [:]
 | |
| 
 | |
|     if let width = videoSettings[AVVideoWidthKey] as? NSNumber,
 | |
|        let height = videoSettings[AVVideoHeightKey] as? NSNumber {
 | |
|       attributes[kCVPixelBufferWidthKey as String] = width as CFNumber
 | |
|       attributes[kCVPixelBufferHeightKey as String] = height as CFNumber
 | |
|     }
 | |
| 
 | |
|     attributes[kCVPixelBufferPixelFormatTypeKey as String] = pixelFormat
 | |
| 
 | |
|     self.init(assetWriterInput: assetWriterInput, sourcePixelBufferAttributes: attributes)
 | |
|   }
 | |
| }
 |