Skip to content

Commit a528625

Browse files
authored
fix(session-replay): revert max key-frame interval to once per video segment (#5156)
1 parent 215095e commit a528625

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- Improve session replay frame presentation timing calculations (#5133)
2525
- Use wider compatible video encoding options for Session Replay (#5134)
2626
- GA of better session replay view renderer V2 (#5054)
27+
- Revert max key-frame interval to once per session replayvideo segment (#5156)
2728

2829
## 8.49.2
2930

Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,12 @@ class SentryOnDemandReplay: NSObject, SentryReplayVideoMaker {
325325
// where each frame is independent and must be decodable on its own.
326326
AVVideoAllowFrameReorderingKey: false,
327327

328-
// Ensures that every frame is a keyframe (also called an I-frame).
329-
// This is crucial in a 1 FPS timelapse context because:
330-
// 1. It guarantees that every frame can be displayed without relying on previous frames.
331-
// 2. It enables precise seeking and smooth scrubbing across all video players.
332-
AVVideoMaxKeyFrameIntervalKey: frameRate // e.g., 1 for 1 FPS
328+
// Sets keyframe interval to one I-frame per video segment.
329+
// This significantly reduces file size (e.g. from 19KB to 9KB) while maintaining
330+
// acceptable seeking granularity. With our 1 FPS recording, this means a keyframe
331+
// will be inserted once every 6 seconds of recorded content, but our video segments
332+
// will never be longer than 5 seconds, resulting in a maximum of 1 I-frame per video.
333+
AVVideoMaxKeyFrameIntervalKey: 6 // 5 + 1 interval for optimal compression
333334
] as [String: Any],
334335

335336
// Explicitly sets the video color space to ITU-R BT.709 (the standard for HD video).

Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class SentryOnDemandReplayTests: XCTestCase {
324324
XCTAssertEqual(compressionProperties[AVVideoAverageBitRateKey] as? Int, sut.bitRate)
325325
XCTAssertEqual(compressionProperties[AVVideoProfileLevelKey] as? String, AVVideoProfileLevelH264MainAutoLevel)
326326
XCTAssertEqual(compressionProperties[AVVideoAllowFrameReorderingKey] as? Bool, false)
327-
XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, sut.frameRate)
327+
XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, 6)
328328

329329
let colorProperties = try XCTUnwrap(settings[AVVideoColorPropertiesKey] as? [String: Any], "Color properties not found")
330330

@@ -353,7 +353,7 @@ class SentryOnDemandReplayTests: XCTestCase {
353353
XCTAssertEqual(compressionProperties[AVVideoAverageBitRateKey] as? Int, sut.bitRate)
354354
XCTAssertEqual(compressionProperties[AVVideoProfileLevelKey] as? String, AVVideoProfileLevelH264MainAutoLevel)
355355
XCTAssertEqual(compressionProperties[AVVideoAllowFrameReorderingKey] as? Bool, false)
356-
XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, sut.frameRate)
356+
XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, 6)
357357

358358
let colorProperties = try XCTUnwrap(settings[AVVideoColorPropertiesKey] as? [String: Any], "Color properties not found")
359359

0 commit comments

Comments
 (0)