Pipeline execution contracts
For contributors implementing processors, persistence, or recovery. User-facing file routing and failure behavior are in the workflow guide.
Processor Result Contracts
Media processors share output planning, sequential execution and single-file skip result construction. Unary audio, metadata, thumbnail and remux jobs use the first output override; their batch jobs require one override per input or none. ASS and DanmakuFactory instead map strictly against selected video/XML inputs. Naming and empty-string policies remain processor-specific.
Audio, metadata, thumbnail and remux use staged publication through the shared driver: every output of a job is written to a temporary file and the whole batch is published together, so a failure or cancellation part-way through a batch publishes nothing, and one item's output can never overwrite another item's input. ASS retains its artifact-matching loop and the same staged publication. Source deletion remains after successful publication, and skipped sources remain. Outputs, succeeded/skipped inputs and logs retain their input order and existing metadata shapes. Batch jobs report the summed input and output sizes of the items they processed.
A processor that reports some of its inputs as failed fails the job, and a workflow step with it, even when the remaining inputs were processed. The error names each failed input. What was published stays on disk and in the job's produced-file history, so a retry resumes past it. An rclone move, rship transfer or BaiduPCS upload that fails part-way records each file's own result instead of marking every file failed. Copy and move steps refuse two inputs that would use the same destination name, and a thumbnail step takes the first frame of a recording shorter than the requested timestamp.
Path mechanisms share filesystem resolution while preserving separate policies: ASS command spelling remains lexical; remux resolves existing relative command paths and uses best-effort, Windows/macOS case-folded comparisons. Staged output validation checks native identity (including hard links), resolves nonexistent leaves through their parents, and propagates I/O errors. Transfer processors still capture sizes before sources can be consumed and treat only confirmed absence as an earlier completed transfer.
Processor contracts and stage checks
Every processor declares a static contract through Processor::contract(); the
trait has no default, so a new processor cannot compile without one. A contract
lists the file kinds it accepts (video, audio, chat for danmu XML,
subtitle for ASS, image, archive, other; empty means any), whether it
needs a single file or a video together with its chat (video_with_chat), what
it produces (same_kind, a list of kinds, passthrough, nothing or
unknown), whether skipped inputs are passed on, which external tools it runs,
and whether it is checked at all. execute declares checked: false. Kinds are
classified from file extensions by the same helper the processors use.
Config-dependent outputs (operation=move, remove_source_after_upload,
passthrough_inputs) are applied when a DAG is analysed, so contracts stay
static. GET /api/pipeline/processors returns the contracts with the stages each
processor fits (segment, paired, session) and the kinds it skips under
segment.
Stage fit is computed, never stored. A video_with_chat processor does not fit
segment, which delivers one file at a time; every other contract fits every
stage. A workflow's compatible stages are the intersection over its resolved,
checked steps, and workflow responses report them as compatible_stages.
POST /api/pipeline/validate accepts an optional stage. Without one, only the
stage-independent rules run. The response adds issues, each with a code,
severity (warning or info), optional step_id, params and an English
message; every warning's message is also appended to warnings for older
clients. Errors remain strings and still block saving; no issue code blocks
saving or running. Unchecked steps and everything downstream of them are exempt
from input_kind_unavailable, upload_receives_derivative_only and
receives_nothing.
| Code | Severity | Raised when |
|---|---|---|
stage_mismatch | warning | The step does not fit the requested stage; params.suggested_stage names one that does |
input_kind_unavailable | warning | No kind the step accepts can reach it. Root steps receive the stage's arrival kinds (segment: video or chat; paired: video and chat; session or no stage: all); other steps receive their parents' effective outputs, plus the parents' inputs when skipped inputs are passed on. Chat reaching ass_burnin counts, because it finds the ASS file through the session pairing |
upload_receives_derivative_only | warning | An rclone, rship, baidupcs or aliyunpan step receives only images, subtitles or archives while the stage's roots include video |
receives_nothing | warning | Every parent of the step produces nothing, such as a step after an rclone move or delete |
skips_other_kind | info | Under segment, a root step accepts only some kinds and skips the rest |
tool_not_found | warning | A required tool does not resolve through the processor's own lookup (configured path, path variable, PATH); results are cached briefly |
deletes_while_read | warning | A step removes its inputs on success while a sibling still reads them |
GET /api/pipeline/lint-report runs the same analysis on every stored stage
(global, platform, template, streamer) with its stage and on every workflow
without one, and returns only entries with at least one warning. It skips the
tool lookup, so tool_not_found never appears there (a missing tool would
otherwise list every built-in workflow that uses it); those warnings stay on the
validate response. An entry whose analysis fails with a repository error is
logged and left out. It is computed on request; nothing is stored.
Skip reasons and step outcomes
A processor reports each input it did not work on as a SkippedInput with a
SkipReason, an optional detail (passed through the same secret scrubber as
logs) and whether the file was passed on. Processors that skip a whole job,
such as ass_burnin without video or danmaku_factory without XML, record one
entry per input. The legacy {"status":"skipped","reason":…} job metadata keeps
its keys.
| Code | Meaning |
|---|---|
wrong_kind | The input is a kind the processor does not accept; detail holds the kind received |
unsupported_format | The processor accepts this kind of file but not its format, such as metadata on .ts; detail holds the extension |
already_image | The input is already an image |
no_video_frames | The input has no video stream to take a frame from |
no_audio_stream | The input has no audio stream |
no_matching_subtitle | No subtitle matches the video |
subtitle_missing | The matched subtitle file does not exist |
subtitle_already_used | The subtitle was already burned into another copy of the recording in this job |
no_output_produced | The tool produced no output, such as DanmakuFactory on an empty chat file |
excluded_by_filter | An exclude pattern matched the input |
unchanged_on_remote | The remote already holds the same file |
file_not_found | The file to delete no longer exists |
no_inputs | A DAG step completed without a job because its dependencies produced nothing |
Skipped inputs are stored in the job's execution info (JSON, so no migration).
The job outcome is derived on read: nothing_to_do when a completed job
skipped every input, partially_skipped when it skipped some, and processed
otherwise, including for jobs recorded before skip reasons existed. Job status
stays COMPLETED, so the status CHECK constraints, triggers and partial indexes
are unaffected. dag_step_execution.outcome stores the step outcome when a step
completes so list and summary queries can count it; a step completed without a
job gets nothing_to_do and the reason no_inputs. DAG list and status
responses add steps_nothing_to_do and an outcome of nothing_to_do when every
step had nothing to do. No WebSocket message or notification event carries the
outcome.
Restart recovery of danmu segments
Recovery associates a stored XML output with the stored video segment whose path
has the same name with its extension replaced by .xml. The stored paths must
match; recovery does not infer an index from title digits or media-output IDs.
If no segment matches, or different segment indices produce the same XML path,
the XML output is skipped with a warning. Keep original video/XML path records
consistent when restoring a database; unmatched historical files are not
automatically assigned to a segment or replayed through paired processing.
Error Handling
Paired-segment and session-complete pipelines receive their video inputs
first, followed by their danmaku inputs. Session-complete inputs are ordered by
segment index; paired inputs retain their collected order. Which danmaku file
belongs to which video is recorded per segment as the pipeline's session
pairing, stored with the pipeline itself and available to every step, including
after a restart or retry. Subtitle conversion and burn-in pair within a segment
only: a segment without a danmaku file leaves its own video without subtitles
and does not shift the pairing of later segments. A subtitle is burned into one
video per job; a second copy of the same recording in the same job is passed
through with a note. No file is written next to the recordings; _inputs.json files left by earlier versions are unused and can
be deleted.
Normal completion and restart recovery collect leaf outputs in DAG definition order, keeping the first occurrence of each path with case folding on Windows and macOS. Missing leaf records or malformed output arrays leave recovery incomplete while preserving the valid outputs. Completing a step twice does not create another downstream job or increment the DAG's completed-step count again.
Delete, rclone, rship and BaiduPCS retry delays grow exponentially but are capped at
30 seconds per wait, including extreme configured values. Retry counts keep
their configured meaning. Before each rclone, rship or BaiduPCS upload retry, the
job log notes the failed attempt and the wait, and the job's progress reports
the retrying phase, without bytes, speed or eta_secs, until the next
attempt starts. From the first retry on, snapshots carry attempt and
max_attempts: the upload's own attempt within one job run, separate from the
job's retry count.
FFmpeg progress timestamps exposed as out_time_ms
are milliseconds for both supported upstream timestamp keys. duration_ms is
the length the run writes: the input length FFmpeg reports, shortened by remux
trimming. percent and eta_secs follow from it, and percent stays below
100 until FFmpeg reports the end. Multi-file jobs report files_done and
files_total; FFmpeg steps leave out inputs they pass through by file type,
such as danmu XML. The percent of a multi-file FFmpeg or DanmakuFactory job
covers the whole job with an equal share per file, while out_time_ms and
duration_ms describe the file in progress. eta_secs covers only that file,
so FFmpeg jobs report it only for their last file. DanmakuFactory reports no
progress within a file, so its jobs show only the file they have reached. Copy
and move jobs count bytes across the whole job, leaving excluded inputs out of
both bytes and files: bytes_done, bytes_total and percent cover every
file the job copies or moves, the speed is that of the file being copied, and
eta_secs is the time the job's remaining bytes take at that speed.
Compression jobs count bytes
across the whole job too; their speed is the average since the job started, and
eta_secs the time the remaining bytes take at that speed. BaiduPCS uploads
count bytes and files across the whole job as well, starting from the files
earlier attempts of the same run uploaded, and report at most once a second;
their speed is the sum of the files BaiduPCS-Go uploads at once. phase is
absent while a job does plain work towards percent. It is finalizing while
FFmpeg rewrites an MP4 after writing its last frame, such as moving the index
to the front for fast start; percent then stops at 99% of the file's share,
with no speed or eta_secs, until FFmpeg reports the end. It is also
finalizing for an rclone or rship job that sent every byte while the destination
confirms the files in flight. It is preparing for a BaiduPCS upload while
none of the files BaiduPCS-Go is working on has shown progress yet, because
before sending a file BaiduPCS-Go checks the Netdisk and hashes the file
without progress output; the job's counts so far stay. It is also preparing
for an rclone or rship job while none of the files in flight has sent data, such as
while hashing a file for a destination that stores a checksum with the
upload (S3 multipart uploads, for example), and before its first transfer,
while listing the destination and comparing the files already there, which
can mean reading a whole file to compare checksums. FFmpeg, copy, compression,
DanmakuFactory, rclone, rship and BaiduPCS jobs name the file in progress in
current_file, without its directories; rclone, rship and BaiduPCS jobs name none
while they send several files at once. raw carries no file paths.
Job progress is kept in memory only. A job has no snapshot until it reports,
including after a restart, and loses it when it ends;
GET /api/pipeline/jobs/{id}/progress returns 404 without one.
Staged outputs with overwrite disabled use native no-replace publication on Windows, Linux and macOS, so a filesystem without hard links can still publish without overwriting a competing file. Systems that support neither no-replace publication nor hard links return an error. Temporary-file cleanup after an abandoned processor runs off the async worker and is best effort; a normal publication waits for its commit or rollback. Subtitle and font paths support apostrophes and filtergraph delimiters without extra user escaping.
- Fail-fast: When a step fails, only the steps that depend on it, directly or through other steps, are cancelled. Steps on independent branches keep running and finish normally; the workflow stays in progress, with the failure recorded as its error, until no step is running, and is then marked failed. A retry re-runs only the failed and cancelled steps.
- Retry: Failed steps can be retried manually or automatically. A retry checks every job it will restart before changing anything; if restarting breaks down part-way, the workflow is failed again with the retry error and stays retryable. A workflow whose cancelled step never received a job can be retried too. At startup, a running step whose job had already failed or been cancelled fails its workflow so it can be retried.
- Logs: Each step maintains execution logs for debugging
Retries and restart recovery retain the job's earlier step timings, log counters, file-size metadata and produced-artifact history. Starting another attempt does not duplicate earlier log entries. The current processor is saved before it runs; if that write fails or stored execution metadata is invalid, processing stops and the failure is reported without replacing the original metadata. Completion and failure updates also preserve additional stored execution-metadata fields.
Produced-artifact history can include files published by earlier attempts. A later failure does not delete those files. Processors manage their own staged temporary outputs, with the cleanup limits described above.