react-native-vision-camera/ios/Extensions/AVAssetWriterInputPixelBufferAdaptor+initWithVideoSettings.swift
Marc Rousavy 71730a73ef
fix: Fix AVAudioSession not allowing background music playback (#155)
* Set category always if different

* rename org

* Fix video format sorting

* fix format filtering

* Update AVAudioSession+setCategoryIfNotSet.swift

* upgrade all dependencies

* Also run dependabot for JS codebase

* Update MediaPage.tsx

* Use typescript 4.2.4

* Also run TS in check-all

* Downgrade typescript to 4.2.3

* f

* recreate lockfiles

* docs: Revert package.json changes

* revert all package.json changes

* Update Podfile.lock

* bump all dependencies, pin typescript to 4.2.4

* Downgrade react-native-navigation for now

* upgrade to later snapshot

* Update yarn.lock

* remove yeet
2021-06-01 13:07:57 +02:00

31 lines
1.1 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]) {
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)
}
}