Repository navigation
fix(playback): stop claiming m2ts/mts direct play - #452
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe Media3 original playback container list no longer includes ChangesBDAV container playback policy
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to M2TS/MTS are no longer advertised for original playback, while other listed TS formats remain eligible. The whole-series Original-quality download exception is documented. No concrete issue in the reviewed change warrants blocking merge; normal checks remain. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)
✨ 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 |
Media3's TsExtractor reads only 188-byte transport-stream packets. Blu-ray and AVCHD .m2ts/.mts files use 192-byte BDAV packets, so no Media3 extractor recognizes them and direct play fails with ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED before recovering through a failure replan to an HLS remux. Drop m2ts and mts from the advertised direct-play containers. The same list feeds the top-level client capabilities, the original_http delivery capability and the download capabilities, so the server now remuxes these files from the start and a download no longer fetches original bytes the player cannot open. ts, mpegts and mpeg-ts stay. The video/mp2t MIME mapping for m2ts/mts in SiloPlayerFactory stays: it is only a hint used when the server still serves original bytes (for example an older server that ignores the capability list), it is the correct MIME type for the format, and it does not change the outcome. Related to Silo-Server#449
442d24b to
52b5c59
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
Superseded: this pass missed two findings. See the later review: #452 (review)
AI disclosure: written by Claude Code (claude-opus-5-5) via a /silo code-review pass.
Quick104
left a comment
There was a problem hiding this comment.
The earlier "no issues" review on this PR was posted in error; these are the code review findings.
Code review found two issues. The fix itself is sound: the server records .m2ts and .mts as m2ts, matches containers by exact name, and on a replan drops the route that failed, so playback and single-title downloads now go through a remux as described.
- Series downloads still fetch the original BDAV bytes (inline comment). Needs your call on where to fix it.
- Low: the playback validation doc is out of date.
docs/playback/02-migration-compatibility-validation.mdline 213 still reads| MOV/QT and TS/M2TS | Test direct, seeking, tracks, subtitles, and recovery; do not force remux solely from the extension. |. After this change, every.m2ts/.mtsfile is remuxed because of its extension-derivedm2tslabel. Someone running the hardware gates would expect M2TS to direct play, report the remux as a regression, or addm2tsback. Suggested repair: split the row so TS stays direct play and M2TS/MTS (BDAV, 192-byte packets) is expected to use server adaptation.
Validation tasks: none, matching the PR body.
AI disclosure: reviewed by claude-opus-5-5 in Claude Code via T3 Code (/silo code-review).
| * 192-byte BDAV packets, and Media3's `TsExtractor` reads only 188-byte | ||
| * transport-stream packets, so no extractor recognizes them and direct play | ||
| * fails with `ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED`. Leaving them out | ||
| * makes the server remux these files instead, which also keeps a download |
There was a problem hiding this comment.
Medium, needs your call: Download series still fetches unplayable originals.
This comment says that leaving m2ts out stops a download from fetching original bytes. That holds for single titles and for season downloads (startSeason downloads one episode at a time). It does not hold for whole-series downloads.
- Trigger: on phone, tap Download series on a show stored as Blu-ray
.m2ts.DownloadEnqueuer.startSeriesforcesDownloadQuality.Originaland sends a series batch. - Why: on the server,
createSeriesScoped(internal/downloads/service.go) setsdecision := originalDecision()and only looks atreq.Capswhenquality != QualityOriginal. Every episode is registered as a raw original, whatever containers the device claims. Single-item downloads go throughDownloadQualityResolver.Resolve, which checks caps and picks a remux. - Impact: each episode downloads as raw BDAV. Offline playback opens it as direct
video/mp2t,TsExtractorrejects the 192-byte packets, and with no server session there is no remux to fall back to. - Suggested repair: fix it on the server by having series batches at Original quality resolve each episode with the device caps, the same way
Resolvedoes for one item. This comment can stay as written once that lands. Until then, narrow it to playback and single-item downloads. Series monitors at the default original quality may use the same path; I didn't check that.
I found this by tracing the code; I didn't reproduce it on a device.
There was a problem hiding this comment.
Narrowed the comment in 6f5913d: it now says the remux covers playback and single-title and season downloads, and that a whole-series download at Original quality still fetches the original bytes because the server skips the capability check for that batch. The server-side fix (resolve each episode in a series batch against the device caps) belongs in silo-server and is a separate change.
The container policy comment said dropping m2ts/mts keeps every download from fetching the original bytes. Whole-series downloads at Original quality still do, because the server does not check device capabilities for that batch. Say so, and split the M2TS row in the playback validation gates so M2TS/MTS is expected to use server adaptation rather than direct play.
|
Split the stale |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Related issue: #449
Validation tasks: none (no passed v1.0 case plays Blu-ray
.m2tsfiles on Android)Android claims it can directly play
m2tsandmts, but Media3'sTsExtractoronly reads 188-byte transport-stream packets. Blu-ray and AVCHD.m2ts/.mtsfiles use 192-byte BDAV packets, so no extractor recognises them: direct play fails withERROR_CODE_PARSING_CONTAINER_UNSUPPORTED, and playback only starts after afailure_recoveryreplan to an HLS remux. An offline download of such a file would fetch the raw.m2ts, which then can't play with no server to fall back to.Today the server never catalogs
.m2ts, so this is latent. Silo-Server/silo-server#1809 makes the scanner catalog them (recorded containerm2ts), after which every.m2tsepisode would hit this. This change should land before or with that PR.Solution
Drop
m2tsandmtsfrommedia3OriginalVideoContainersinPlaybackContainerPolicy.kt, with a comment explaining why and when to add them back (Media3 support for 192-byte packets plus a device test). That one list feeds the top-levelclient_capabilities.containers,original_http.containersand the download capabilities, so the server now remuxes these files from the start and downloads single titles and season episodes as a remux. A whole-series download at Original quality still fetches the original file, because the server does not check device capabilities for that batch; that needs a server-side fix.ts,mpegtsandmpeg-tsstay. Them2ts/mts→video/mp2tMIME mapping inSiloPlayerFactory.ktstays as a correct hint for servers that still send the original file.Validation
./gradlew :android-shared:testDebugUnitTest :android-shared:lintDebugpasses (1656 tests).PlaybackContainerPolicyTestgains a check thatm2ts/mtsare not claimed.Silo_Phone, API 36) against a local server built from silo-servermainplus #1809, with a real BDAV.m2tsepisode (H.264 + AC-3, 192-byte packets):startPlayback→ directGET /api/v2/stream/{id}→UnrecognizedInputFormatException/ERROR_CODE_PARSING_CONTAINER_UNSUPPORTEDin logcat →replanPlayback→ HLS; about 2.6 s to a ready player.startPlayback→ HLS manifest directly (play_method=remux,output_container=fmp4,output_protocol=hls), no failed attempt or replan; about 1.2 s to a ready player.POST /api/v2/downloadsfor the same.m2tsfile returneddelivery_format: originalwith the old claimed containers anddelivery_format: remuxwith the new ones. The in-app download flow was not exercised.Risks
None identified. A
.m2tsfile now always goes through a server-side remux (a codec copy, no transcode) instead of a failed direct-play attempt. If a future Media3 release reads 192-byte packets, the containers can be claimed again after a device test.Checklist
AI disclosure
Note
Remove
m2ts/mtsfrom Media3 direct-play containers inPlaybackContainerPolicyTsExtractorreads 188-byte TS packets, butm2ts/mtsuse 192-byte BDAV packets, so these formats were being misclassified as directly playable. They now fall back to server remux/adaptation.m2ts/mtsexclusion in PlaybackContainerPolicyTest.kt.m2ts/mtsfiles take the server remux path instead of direct playback.Macroscope summarized 6f5913d.