Skip to content

Commit

Permalink
fix system audio; fix bitrate
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyun6 committed Jun 20, 2024
1 parent 6c2c6f7 commit 3a6e8cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
16 changes: 11 additions & 5 deletions QuickRecorder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1510;
LastUpgradeCheck = 1510;
LastUpgradeCheck = 1600;
TargetAttributes = {
18D3BDE62BCE5DC1006CFFC0 = {
CreatedOnToolsVersion = 15.1;
Expand Down Expand Up @@ -299,6 +299,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -328,6 +329,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -362,6 +364,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -391,6 +394,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -420,7 +424,8 @@
CODE_SIGN_ENTITLEMENTS = QuickRecorder/QuickRecorder.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 138;
CURRENT_PROJECT_VERSION = 139;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"QuickRecorder/Preview Content\"";
DEVELOPMENT_TEAM = L4T783637F;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -437,7 +442,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 1.3.8;
MARKETING_VERSION = 1.3.9;
PRODUCT_BUNDLE_IDENTIFIER = com.lihaoyun6.QuickRecorder;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -453,7 +458,8 @@
CODE_SIGN_ENTITLEMENTS = QuickRecorder/QuickRecorder.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 138;
CURRENT_PROJECT_VERSION = 139;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"QuickRecorder/Preview Content\"";
DEVELOPMENT_TEAM = L4T783637F;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -470,7 +476,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 1.3.8;
MARKETING_VERSION = 1.3.9;
PRODUCT_BUNDLE_IDENTIFIER = com.lihaoyun6.QuickRecorder;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
11 changes: 9 additions & 2 deletions QuickRecorder/RecordEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ extension AppDelegate {
}

if #available(macOS 13, *) {
conf.capturesAudio = ud.bool(forKey: "recordWinSound") || fastStart
conf.capturesAudio = ud.bool(forKey: "recordWinSound") || fastStart || audioOnly
conf.sampleRate = SCContext.audioSettings["AVSampleRateKey"] as! Int
conf.channelCount = SCContext.audioSettings["AVNumberOfChannelsKey"] as! Int
}
Expand Down Expand Up @@ -255,7 +255,14 @@ extension AppDelegate {
let encoderIsH265 = (ud.string(forKey: "encoder") == Encoder.h265.rawValue) || recordHDR
let fpsMultiplier: Double = Double(ud.integer(forKey: "frameRate"))/8
let encoderMultiplier: Double = encoderIsH265 ? 0.5 : 0.9
let targetBitrate = (Double(max(600, conf.width)) * Double(max(600, conf.height)) * fpsMultiplier * encoderMultiplier * ud.double(forKey: "videoQuality"))
let resolution = Double(max(600, conf.width)) * Double(max(600, conf.height))
var qualityMultiplier = 1 - (log10(sqrt(resolution) * fpsMultiplier) / 5)
switch ud.double(forKey: "videoQuality") {
case 0.3: qualityMultiplier = max(0.1, qualityMultiplier)
case 0.7: qualityMultiplier = max(0.4, min(0.6, qualityMultiplier * 3))
default: qualityMultiplier = 1.0
}
let targetBitrate = resolution * fpsMultiplier * encoderMultiplier * qualityMultiplier
var videoSettings: [String: Any] = [
AVVideoCodecKey: encoderIsH265 ? ((ud.bool(forKey: "withAlpha") && !recordHDR) ? AVVideoCodecType.hevcWithAlpha : AVVideoCodecType.hevc) : AVVideoCodecType.h264,
// yes, not ideal if we want more than these encoders in the future, but it's ok for now
Expand Down

0 comments on commit 3a6e8cd

Please sign in to comment.