# FFmpeg Media

FFmpeg media processing API: transcode, compress, scale, trim, frame extraction, single-frame grab, watermark, subtitle burn-in, character nameplates, concat, concat with transitions, mux, timeline audio mux, audio extraction, GIF conversion, thumbnail, media probe, deep QC, and file upload.

Flow: (1) upload a file to get a CDN URL → (2) call an operation (use that URL as input) → (3) poll by taskId until succeeded / failed.

Inputs only accept URLs on a trusted allowlist domain (platform CDN or a trusted-source CDN); if an asset is already on a trusted CDN you can skip upload and use it directly. Billed by credits: charged when the task starts running (the price can only be determined after probing the input), not yet charged while queued, auto-refunded in full on failure; invalid parameters and insufficient balance are rejected before any charge.

A busy platform is not an error: when every node is busy, submit still returns a taskId and the task waits as queued, then starts automatically — just keep polling, no need to retry yourself.

## Operations
- **Upload File** (`upload`) — Upload a media file (multipart); returns a CDN URL synchronously.
- **Media Probe** (`probe`) — Extract media metadata: duration / resolution / bitrate / codec. Returns instantly.
- **Deep QC** (`qc`) — Read-only QC: decodes the finished video twice (one video pass, one audio pass) with detector filters and returns a small JSON report — black-frame, freeze and silence segments plus EBU R128 loudness. It produces no media file and leaves the source untouched.
- **Transcode** (`transcode`) — Convert container format and audio/video codecs.
- **Compress** (`compress`) — Reduce video file size.
- **Scale** (`scale`) — Scale the video to a target resolution.
- **Trim** (`trim`) — Cut a time segment out of the video.
- **Extract Audio** (`extract_audio`) — Extract the audio track from a video.
- **Video to GIF** (`to_gif`) — Convert a video segment to an animated GIF.
- **Thumbnail** (`thumbnail`) — Capture a single frame at a given time.
- **Watermark** (`watermark`) — Overlay an image watermark on the video.
- **Burn Subtitle** (`burn_subtitle`) — Add subtitles to a video: soft = a switchable subtitle track (no re-encode); hard = burned into the pixels (permanent, forces a re-encode).
- **Character Nameplate** (`overlay_text`) — Burn 1-4 lower-third nameplates (character name + role subtitle, each with its own time window) into the video. Video is re-encoded, the audio track is stream-copied, and resolution / frame rate / SAR stay identical to the source.
- **Concat** (`concat`) — Join multiple videos into one, in order.
- **Mux Audio** (`mux`) — Merge audio into video (replace or add a track).
- **Extract Frames** (`frames`) — Export image frames by interval or FPS; the output is packaged into a single .zip and resultUrl points to that archive.
- **Extract Single Frame** (`extract_frame`) — Extract one frame from a video: the last frame or a given timestamp; output keeps the original resolution without scaling.
- **Timeline Audio Mux** (`mux_timeline`) — Place multiple audio clips into a video at their own time offsets — positioning and muxing the whole track in one call.
- **Concat with Transitions** (`concat_transition`) — Join clips in order with optional crossfade or dip-to-black transitions at chosen seams, plus head fade-in and tail fade-out.

> This page uses the unified API: create with `POST /v1/ffmpeg/jobs` (`operation` names the operation), poll with `GET /v1/ffmpeg/jobs/{id}`. File upload still uses `POST /v1/ffmpeg/upload`.

## Polling
Poll `GET /v1/ffmpeg/jobs/{id}` until `status` is `completed` or `failed`; a failed job is still HTTP 200 with `error`.
