Repository navigation
Closed
Description
Problem
Prepared offline downloads currently execute FFmpeg on the API/integrated worker and serve the completed bytes from that same process. This bypasses the transcode-node scheduler and proxy-node egress path used by playback. The separate PrepareFile argument path has also drifted from transcode.go: codec-specific software-decode fallback is applied to streaming but not prepared downloads.
This is the prepared-download counterpart to #326 and builds on the download-quality work in #301.
Proposed direction
Keep download_artifacts and its durable lease/heartbeat state on the API node, but make execution and delivery node-aware:
- Normalize
TranscodeOptsthrough one playback-owned helper before both HLS and single-file FFmpeg argument construction. - Select a healthy transcode node for prepared-file work when one is available. Send an authenticated internal prepare request carrying the resolved recipe and deterministic output path; fall back to local preparation when no eligible node exists.
- Preserve cancellation and lease fencing so a lost artifact lease aborts either a local or remote FFmpeg process.
- After the API has authenticated the download and re-checked current policy/content access, redirect file transfer to a healthy proxy node with a short-lived signed download claim. The proxy verifies the claim and serves original or prepared bytes with Range/HEAD support. Fall back to API-local serving when no proxy is available.
- Count remote preparation in node load/health reporting and emit enough structured logging to identify the selected execution and egress nodes.
Constraints
- Existing integrated deployments must continue to work without configured nodes.
- The central API remains authoritative for download authorization, status transitions, quotas, artifact leases, and retries.
- Node requests use the existing internal bearer trust boundary; clients never choose filesystem paths or nodes.
- Prepared output paths must be available to the selected transcode/proxy nodes. Missing or divergent mounts fail safely and use the documented fallback behavior.
/api/v1remains additive-only.- Original and remux downloads must not be forced through a video encoder.
Acceptance criteria
- QSV, VAAPI, and NVENC prepared downloads use the same codec/decode fallback decisions as streaming, including H.264 High 10 handling.
- A prepared download uses a healthy transcode node when available and local FFmpeg otherwise.
- Cancellation or lease loss terminates remote preparation and never marks an incomplete artifact ready.
- Authorized original and prepared downloads use a healthy proxy node for GET/HEAD and byte ranges, with API-local fallback.
- Tokens are short-lived and signed; proxy routes reject missing, expired, or invalid claims.
- Existing download lifecycle, deduplication, retry, quota, and access-control tests continue to pass.
- New focused tests cover shared recipe normalization, remote preparation, proxy delivery, and local fallback.
Related
- Direct downloads are served by the API server instead of delegating to a proxy node #326
- [v1] Transcoding option for downloads (choose quality/bitrate profile before offline download) #301
AI Disclosure
- Tool(s): Codex in T3 Code
- Model(s): gpt-5.6-sol
- Involvement: fully AI-generated
- Adversarial review: issue scope was checked against the existing download artifact queue, transcode-node planner, and proxy delivery paths; the implementation review is documented in the follow-up PR.
Metadata
Metadata
Assignees
Labels
No labels
Activity