Skip to content

Commit

Permalink
Swiftformat
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed May 6, 2021
1 parent e03197a commit 0f753cd
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,25 @@
// Copyright © 2021 Facebook. All rights reserved.
//

import Foundation
import AVFoundation
import Foundation

extension AVAssetWriterInputPixelBufferAdaptor {
/**
Convenience initializer to extract correct attributes from the given videoSettings.
*/
convenience init(assetWriterInput: AVAssetWriterInput, withVideoSettings videoSettings: [String: Any]) {
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
}

// TODO: Is "Bi-Planar Y'CbCr 8-bit 4:2:0 full-range" the best CVPixelFormatType? How can I find natively supported ones?
attributes[kCVPixelBufferPixelFormatTypeKey as String] = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange

self.init(assetWriterInput: assetWriterInput, sourcePixelBufferAttributes: attributes)
}

}

0 comments on commit 0f753cd

Please sign in to comment.