diff --git a/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift b/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift index 0c4a1bcec7..5851e5a842 100644 --- a/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +++ b/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift @@ -88,7 +88,10 @@ func run() throws { let renderSize = resolvedRenderSize(for: sourceVideoTrack) let videoComposition = AVMutableVideoComposition() videoComposition.renderSize = renderSize - videoComposition.frameDuration = resolvedFrameDuration(for: sourceVideoTrack) + videoComposition.frameDuration = resolvedFrameDuration( + for: sourceVideoTrack, + maximumFrameRate: parsedArgs.maximumFrameRate + ) let instruction = AVMutableVideoCompositionInstruction() instruction.timeRange = fullRange @@ -158,11 +161,15 @@ func run() throws { func parseArguments( _ arguments: [String] -) throws -> (inputPath: String, outputPath: String, eventsPath: String, timeoutSeconds: Double) { +) throws -> ( + inputPath: String, outputPath: String, eventsPath: String, timeoutSeconds: Double, + maximumFrameRate: Int32 +) { var inputPath: String? var outputPath: String? var eventsPath: String? var timeoutSeconds = defaultRecordingExportTimeoutSeconds + var maximumFrameRate = maximumCompositedFrameRate var index = 0 while index < arguments.count { @@ -194,6 +201,13 @@ func parseArguments( } timeoutSeconds = milliseconds / 1000 index += 2 + case "--max-fps": + let rawValue = try recordingOptionValue(arguments, nextIndex, "--max-fps") + guard let framesPerSecond = Int32(rawValue), framesPerSecond > 0 else { + throw RecordingScriptError.invalidArgs("--max-fps must be a positive integer") + } + maximumFrameRate = min(framesPerSecond, maximumCompositedFrameRate) + index += 2 default: throw RecordingScriptError.invalidArgs("Unknown argument: \(argument)") } @@ -201,10 +215,10 @@ func parseArguments( guard let inputPath, let outputPath, let eventsPath else { throw RecordingScriptError.invalidArgs( - "Usage: recording-overlay.swift --input