Repository navigation
feat(media): choose HLS/DASH quality, merge separate audio and decrypt AES-128 HLS - #584
Merged
Merged
Conversation
…t AES-128 HLS - HLS variants and DASH video representations resolve as a single choice (FileSelectionMode.SINGLE), best first with video before audio-only; a selection made while downloading restarts with that variant - Separate fragmented MP4 audio (an HLS AUDIO rendition, the main DASH audio adaptation set) is merged with the video into one MP4 by rewriting box headers, fragments interleaved by start time - AES-128 HLS segments are decrypted as they arrive with a pure Kotlin AES-128-CBC decryptor; SAMPLE-AES and other DRM stay refused - The add sheet downloads the best variant instead of offering stream variants as torrent-style checkboxes - Real ffmpeg fixtures (DASH with separate tracks, encrypted HLS fMP4 with a separate audio rendition) back an end-to-end integration test
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b98feede2d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ep boxes before mdat - Variant IDs are hashes of each variant's manifest identity rather than positions, so a refreshed or re-signed manifest cannot map a resumed task's chosen ID to another quality - A variant whose container differs from the output name Ketch chose fails instead of writing TS bytes under .mp4; a file destination the user named is left alone - Boxes between a moof and its mdat are kept, as trun data offsets count them - HLS IVs of any width up to 32 hex digits are left-padded, per RFC 8216
Contributor
…ia-formats # Conflicts: # AGENTS.md
…ia-formats # Conflicts: # AGENTS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the roadmap item "More HLS and DASH formats".
What changes
ResolvedSource.fileswithFileSelectionMode.SINGLE, best first (video before audio-only, then by declared bandwidth; FFmpeg's masters list the audio-only stream as a higher-bandwidth variant). Both sources implementplanSelectionand listdownload.fileSelection/download.awaitFileSelection. A selection made while downloading restarts the transfer with that variant (MediaDownloadHelper.downloadFollowingSelection). A download whose manifest no longer lists the chosen ID's bandwidth fails instead of downloading another quality.AUDIOrendition and a DASH presentation's main audio adaptation set are merged with the video into one fragmented MP4 when both are fMP4 (mergeTracks,Mp4Tracks.kt). The two init segments become onemoov(video track 1, audio track 2, audio durations rescaled). Each fragment streams throughFragmentRewriter, which keepsmoof/mdat, renumbers sequences and track IDs and moves absolute base data offsets. Fragments are interleaved by start time. Samples are never decoded.EXT-X-KEY:METHOD=AES-128(identity key format; an IV, else the media sequence number) is decrypted as bytes arrive by a pure KotlinAes128CbcDecryptor, so it works on every engine target. SAMPLE-AES and other DRM are still refused.docs/media.md, all READMEs (roadmap item removed), CLI, extension and API docs,AGENTS.md.Still unsupported: separate audio for MPEG-TS/AAC/MP3 HLS, picking an audio language, live streams, DRM.
Testing
planSelection).library/ktor/src/jvmTest/resources/media/{dash-tracks,hls-tracks}, regeneration steps in their README): DASH with two video representations and separate AAC, and HLS fMP4 with a separate audio rendition whose segments are AES-128 encrypted with OpenSSL.MediaDownloadIntegrationTestchecks the merged file holds both tracks and every fragment's decrypted media in order. Locally the merged outputs decode withffmpeg(H.264 + AAC; audio frame counts match the sources: 16 and 17).:library:ktor:jvmTest,:app:shared:jvmTest,:cli:test,:library:server:test,:library:mcp:test.wasmWasiNodeTestfails inAwaitFileSelectionTest. That failure reproduces on a cleanmainand is tracked separately.