Skip to content

fix(session-replay): revert max key-frame interval to once per video segment #5156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,12 @@
// 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

Check warning on line 333 in Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift#L328-L333

Added lines #L328 - L333 were not covered by tests
] as [String: Any],

// Explicitly sets the video color space to ITU-R BT.709 (the standard for HD video).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down
Loading