fix(playback): avoid unnecessary HDR video transcodes#418
Conversation
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughHDR playback now retries alternate files for eligible terminal outcomes and permits detailed hardware decoding despite reported bitrate limits. Tests cover alternate-selection rules and HDR decode eligibility. ChangesHDR playback handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/api/handlers/playback_v3.go (1)
1216-1218: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider reusing
shouldTryAlternateAfterTerminalV3to avoid duplicating terminal reason strings.You can use the new helper function here to centralize the list of recoverable terminal reasons. Although this evaluates
shouldTryAlternateFileV3(start.QualityPreference)twice (once inside the new helper and once insidereplanAllowsAlternateFileV3), the overhead is negligible and it keeps the code DRY.♻️ Proposed refactor
if result.Terminal != nil && - (result.Terminal.Reason == "no_alternate_version" || result.Terminal.Reason == "hdr_transcode_unsupported") && + shouldTryAlternateAfterTerminalV3(result.Terminal.Reason, start.QualityPreference) && replanAllowsAlternateFileV3(operation, start.QualityPreference) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/api/handlers/playback_v3.go` around lines 1216 - 1218, Update the terminal-condition check in the playback handler to reuse shouldTryAlternateAfterTerminalV3 instead of duplicating the "no_alternate_version" and "hdr_transcode_unsupported" reason comparisons. Keep replanAllowsAlternateFileV3 as the alternate-file eligibility check and preserve the existing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/api/handlers/playback_v3.go`:
- Around line 1216-1218: Update the terminal-condition check in the playback
handler to reuse shouldTryAlternateAfterTerminalV3 instead of duplicating the
"no_alternate_version" and "hdr_transcode_unsupported" reason comparisons. Keep
replanAllowsAlternateFileV3 as the alternate-file eligibility check and preserve
the existing behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ad16c8f9-dbb7-466e-b46f-0ff5b5a6eb2a
📒 Files selected for processing (4)
internal/api/handlers/playback_v3.gointernal/api/handlers/playback_v3_test.gointernal/playback/capabilities_v3.gointernal/playback/capabilities_v3_test.go
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
MediaCodec's reportedbitrateRangeas a hard hardware decode ceiling.originalpreference and existing 4K-transcode policy.Why
Android TV devices such as NVIDIA Shield can direct-play HDR/HEVC files whose bitrate exceeds the conservative bitrate reported by
MediaCodec. The old gate routed those files into video adaptation, where HDR encoding is intentionally unavailable, producinghdr_transcode_unsupportedbefore the device ever received a media source.Bitrate should influence buffering and quality selection, not declare a hardware decoder incapable of accepting a stream. Resolution, frame rate, codec, profile, and bit depth remain validated.
Verification
go test ./internal/playback ./internal/api/handlers -run 'TestDetailedVideoEligibilityDoesNotRejectHardwareForReportedBitrate|TestShouldTryAlternateAfterTerminalV3AvoidsHDRTranscode|TestReplanAllowsAlternate'git diff --checkThe focused tests pass on current
upstream/main(95779c47).Summary by CodeRabbit
Bug Fixes
Tests