Skip to content

Pipelines #247

Open
3 of 4 issues completed
Open

Description

@s3rot0n1n

Process uploaded files in the background: HLS streaming, captions, and later content protection. What runs on an upload is set by the app's media settings.

Plan

The work is split into four phases. Each phase is a sub-issue with its own sub-issues.

  1. Phase 0: base system (Pipelines phase 0: jobs, derivatives and webhooks #257). Job queue and workers, derivatives and processing status, webhooks, and moving today's WebP and thumbnail processing onto the new system. No new features for users.
  2. Phase 1: video and media processing (Pipelines phase 1: video streaming and media processing #258). HLS with adaptive bitrate (HLS for video streaming #139), MP4 optimized for web playback (Video step: MP4 optimized for web playback #264), and the internal processing they need (metadata, posters, audio extraction).
  3. Phase 2: transcription and captions (Pipelines phase 2: transcription and captions #259).
  4. Phase 3: content protection (Pipelines phase 3: content protection #260). HLS encryption, DRM and watermarking.

Phase 0 blocks everything else. Phase 3 depends on HLS (#139).

A phase is complete only when its observability ships with it (see Decisions).

How users choose what runs: media settings

Each app turns processing on or off in its media settings, the same way useWebP, webpOutputQuality and the thumbnail size work today. There's no pipeline language, no preset editor and no list of steps for users to configure. Mux and Bunny Stream work the same way.

Setting Values Default Issue
videoStreaming "off" | "hls" | "mp4" "hls" for new apps, "off" for existing apps #139, #264
hlsRenditions e.g. ["1080p", "720p", "480p"] ["1080p", "720p", "480p"] #139
generateCaptions boolean false #269
encryption (later) "off" | "aes128" "off" #271
  • On upload, the API reads the app's settings and queues the jobs they turn on. Outputs are stored as derivatives (Store processing outputs as derivatives and track processing status #261), e.g. media.derivatives.hls or media.derivatives.mp4, and a webhook (Webhooks when media processing finishes or fails #198) fires when processing finishes or fails.
  • Settings are managed through the REST API, MCP tools, CLI and the dashboard, like the existing media settings.
  • Changing a setting affects new uploads only. Running processing again on existing media can come later.
  • Internal steps (metadata, posters, audio extraction) have no settings. They run when a feature needs them.

Later

  • Named presets. If one app needs different processing for different uploads (e.g. HLS and captions for lesson videos, nothing for marketing clips), the app's settings become its default preset, and named presets can be added next to it. An upload would choose a preset, and the upload signature could pin it. Nothing built for settings would be thrown away.
  • More settings such as aiSummary and aiTags, if summarizing and tagging come back into scope (AI steps: summarize, tag and extract text #270).
  • URL-based image transforms ([competitive] URL-based image transforms (?w=400) #196) are a separate feature for making image variants on request.

Decisions

  • Settings over pipelines. See above. Named presets and custom steps wait until customers ask for them.
  • Self-hosting supports every feature. None depends on an outside service.
  • No hosted AI providers in the first version. Transcription uses Whisper running in our own pods, for the cloud and for self-hosted installs, so generateCaptions needs no API key. A hosted provider such as ElevenLabs Scribe can be added later behind the provider interface (Transcription and captions (WebVTT) #269).
  • Billing. Processing is metered per minute, separately from storage.
  • Plans. HLS is on by default for self-hosted (OSS) installs and the paid plan. Self-hosted installs aren't metered. The free plan includes 5 processing minutes a month, and the paid plan includes a larger monthly allowance. Accounts can buy extra minutes as an add-on.
  • Out of minutes. Skip the processing and keep the original file playable. Mark the derivative as failed with a clear reason (out_of_processing_minutes). The media itself settles ready, not failed, because it is still usable, so the webhook sent is media.processing.ready, with the failed derivative and its reason in the payload. failed means only that the media isn't usable. The same applies when our size or length limits refuse a video. See D12 in the phase 1 design (Pipelines phase 1: video streaming and media processing #291).
  • Observability is part of done. Every phase ships with its observability through @codelitdev/observability, as SendLit does: product events for the key moments (e.g. media sealed, processing settled, video encoded, out of minutes), log lines for each step, exceptions for failures that are ours to fix (not for a tenant's bad input), and alerts where a stuck or failing queue needs a person. Events carry only IDs, enums, counts, sizes and durations, never file names, URLs or secrets. A phase isn't closed until these are in place and tested. Phase 0 shipped job logs, exceptions and alerts but no product events and few logs for upload, seal, processing and webhooks. Phase 1 closes those gaps first (Pipelines phase 1: video streaming and media processing #258).
  • Language. Workers stay in TypeScript. ffmpeg and libvips do the heavy work, so a Rust rewrite wouldn't make processing measurably faster.
  • Out of scope for now. Summarizing, tagging and extracting text (AI steps: summarize, tag and extract text #270, closed).

Open decisions

  • Metering images and documents. They have no duration, so per-minute metering doesn't cover them. They need another unit, such as per image or per page, or a conversion into minutes.
  • Paid plan allowance. How many minutes the paid plan includes. A first estimate from AWS costs is 300 to 500 minutes a month. Check it against the transcription benchmark (Transcription and captions (WebVTT) #269) and an HLS encoding benchmark before launch.

Sub-issues

Sub-issues

3 of 4 Issues completed
Loading 4 sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions