Skip to content

Commit

Permalink
Fix custom background color not work
Browse files Browse the repository at this point in the history
  • Loading branch information
vitoziv committed May 24, 2021
1 parent 8fa17a1 commit 61c64d3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Cabbage/Sources/Core/Video/VideoCompositor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ open class VideoCompositor: NSObject, AVFoundation.AVVideoCompositing {

public var sourcePixelBufferAttributes: [String : Any]? =
[String(kCVPixelBufferPixelFormatTypeKey): kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,
String(kCVPixelBufferOpenGLESCompatibilityKey): true]
String(kCVPixelBufferOpenGLESCompatibilityKey): true,
String(kCVPixelBufferMetalCompatibilityKey): true]

public var requiredPixelBufferAttributesForRenderContext: [String : Any] =
[String(kCVPixelBufferPixelFormatTypeKey): kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,
String(kCVPixelBufferOpenGLESCompatibilityKey): true]
[String(kCVPixelBufferPixelFormatTypeKey): kCVPixelFormatType_32BGRA,
String(kCVPixelBufferOpenGLESCompatibilityKey): true,
String(kCVPixelBufferMetalCompatibilityKey): true]

open func renderContextChanged(_ newRenderContext: AVVideoCompositionRenderContext) {
renderContextQueue.sync(execute: { [weak self] in
Expand Down Expand Up @@ -72,7 +74,7 @@ open class VideoCompositor: NSObject, AVFoundation.AVVideoCompositing {

// Background
let backgroundImage = CIImage(color: instruction.backgroundColor).cropped(to: image.extent)
image = backgroundImage.composited(over: image)
image = backgroundImage

if let destinationImage = instruction.apply(request: request) {
image = destinationImage.composited(over: image)
Expand Down

0 comments on commit 61c64d3

Please sign in to comment.