Skip to content

Commit 307febf

Browse files
committed
feat(capture): adjusted video export bitrates and keyframe intervals, removed specific compression properties, and set global high interpolation quality for camera video rendering.
1 parent 2a945c4 commit 307febf

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

Reframed/Compositor/CameraVideoCompositor.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ final class CameraVideoCompositor: NSObject, AVVideoCompositing, @unchecked Send
7878
return
7979
}
8080

81+
context.interpolationQuality = .high
82+
8183
let canvasRect = CGRect(x: 0, y: 0, width: width, height: height)
8284

8385
drawBackground(in: context, rect: canvasRect, instruction: instruction, colorSpace: colorSpace)
@@ -152,7 +154,6 @@ final class CameraVideoCompositor: NSObject, AVVideoCompositing, @unchecked Send
152154
if instruction.videoCornerRadius <= 0 {
153155
context.clip(to: videoRect)
154156
}
155-
context.interpolationQuality = .high
156157
context.draw(img, in: drawRect)
157158
} else {
158159
context.draw(img, in: videoRect)

Reframed/Compositor/VideoCompositor.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,13 @@ enum VideoCompositor {
450450
AVVideoHeightKey: Int(renderSize.height),
451451
]
452452
} else {
453-
let compressionProperties: [String: Any]
453+
var compressionProperties: [String: Any]
454454
if codec == .hevc {
455-
compressionProperties = [AVVideoAverageBitRateKey: pixels * exportFPS * 0.04]
455+
compressionProperties = [AVVideoAverageBitRateKey: pixels * exportFPS * 0.07]
456456
} else {
457-
compressionProperties = [AVVideoAverageBitRateKey: pixels * exportFPS * 0.06]
457+
compressionProperties = [AVVideoAverageBitRateKey: pixels * exportFPS * 0.1]
458458
}
459+
compressionProperties[AVVideoMaxKeyFrameIntervalKey] = exportFPS
459460
videoSettings = [
460461
AVVideoCodecKey: codec,
461462
AVVideoWidthKey: Int(renderSize.width),
@@ -779,19 +780,16 @@ enum VideoCompositor {
779780
let exportFPS = Double(fps)
780781
let bitRate: Double
781782
if codec == .h265 {
782-
bitRate = pixels * exportFPS * 0.04
783+
bitRate = pixels * exportFPS * 0.07
783784
} else {
784-
bitRate = pixels * exportFPS * 0.06
785+
bitRate = pixels * exportFPS * 0.1
785786
}
786-
var compressionProperties: [String: Any] = [
787+
let compressionProperties: [String: Any] = [
787788
AVVideoAverageBitRateKey: bitRate,
788789
AVVideoAllowFrameReorderingKey: false,
789790
AVVideoExpectedSourceFrameRateKey: fps,
790-
kVTCompressionPropertyKey_RealTime as String: true,
791+
AVVideoMaxKeyFrameIntervalKey: fps,
791792
]
792-
if codec == .h265 {
793-
compressionProperties[kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality as String] = true
794-
}
795793
videoOutputSettings = [
796794
AVVideoCodecKey: videoCodec,
797795
AVVideoWidthKey: Int(renderSize.width),

0 commit comments

Comments
 (0)