diff --git a/CHANGELOG.md b/CHANGELOG.md index a8789d52d4..cc0056bbae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Improve session replay frame presentation timing calculations (#5133) - Use wider compatible video encoding options for Session Replay (#5134) - GA of better session replay view renderer V2 (#5054) +- Revert max key-frame interval to once per session replayvideo segment (#5156) ## 8.49.1 diff --git a/Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift b/Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift index e3195440e8..4fdbfe8558 100644 --- a/Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift +++ b/Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift @@ -325,11 +325,12 @@ class SentryOnDemandReplay: NSObject, SentryReplayVideoMaker { // where each frame is independent and must be decodable on its own. AVVideoAllowFrameReorderingKey: false, - // Ensures that every frame is a keyframe (also called an I-frame). - // This is crucial in a 1 FPS timelapse context because: - // 1. It guarantees that every frame can be displayed without relying on previous frames. - // 2. It enables precise seeking and smooth scrubbing across all video players. - AVVideoMaxKeyFrameIntervalKey: frameRate // e.g., 1 for 1 FPS + // Sets keyframe interval to one I-frame per video segment. + // This significantly reduces file size (e.g. from 19KB to 9KB) while maintaining + // acceptable seeking granularity. With our 1 FPS recording, this means a keyframe + // will be inserted once every 6 seconds of recorded content, but our video segments + // will never be longer than 5 seconds, resulting in a maximum of 1 I-frame per video. + AVVideoMaxKeyFrameIntervalKey: 6 // 5 + 1 interval for optimal compression ] as [String: Any], // Explicitly sets the video color space to ITU-R BT.709 (the standard for HD video). diff --git a/Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift b/Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift index 60e3aacc18..0f92e4e209 100644 --- a/Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift +++ b/Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift @@ -324,7 +324,7 @@ class SentryOnDemandReplayTests: XCTestCase { XCTAssertEqual(compressionProperties[AVVideoAverageBitRateKey] as? Int, sut.bitRate) XCTAssertEqual(compressionProperties[AVVideoProfileLevelKey] as? String, AVVideoProfileLevelH264MainAutoLevel) XCTAssertEqual(compressionProperties[AVVideoAllowFrameReorderingKey] as? Bool, false) - XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, sut.frameRate) + XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, 6) let colorProperties = try XCTUnwrap(settings[AVVideoColorPropertiesKey] as? [String: Any], "Color properties not found") @@ -353,7 +353,7 @@ class SentryOnDemandReplayTests: XCTestCase { XCTAssertEqual(compressionProperties[AVVideoAverageBitRateKey] as? Int, sut.bitRate) XCTAssertEqual(compressionProperties[AVVideoProfileLevelKey] as? String, AVVideoProfileLevelH264MainAutoLevel) XCTAssertEqual(compressionProperties[AVVideoAllowFrameReorderingKey] as? Bool, false) - XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, sut.frameRate) + XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, 6) let colorProperties = try XCTUnwrap(settings[AVVideoColorPropertiesKey] as? [String: Any], "Color properties not found")