Documentation
¶
Overview ¶
Package transcode is transcode's media vocabulary: the input model a plan is made from, and the types the standard (pkg/transcode/standard) and the in-process engine (pkg/transcode/engine) share. Nothing here runs ffmpeg; since the argv engine was deleted (ffgo spec, Phase 5) every transcode runs in-process on FFmpeg 9's libraries through ffgo.
FromProbe adapts a github.com/mediactl/clustarr/pkg/mediainfo probe (commonv1.MediaInfo plus mediainfo.Raw) into this package's MediaInfo; FromSummary builds the same model from the commonv1.MediaInfo summary alone, which is all a MediaFile's status stores. The standard takes nothing from a probe that the summary lacks, so the controller's recorded plan (from the stored summary) hashes as the worker's (from a live probe).
Tier, Limits and Decoders (NVDEC's measured decode set, with a static Turing list as the fallback) describe the device a plan runs on; EightBitTarget and TooManyStreams are the two rules the controller and the standard share; Progress and Report are the engine's telemetry and verification. A profile reaches the standard as standard.Profile (app/transcode/jobspec.StandardProfile); this package mirrors only its Container and Hardware enums.
This package carries no Kubernetes types beyond commonv1.MediaInfo, and no float crosses into CRD status: Progress is scaled integers.
Index ¶
- Constants
- Variables
- func EightBitTarget(v VideoStream) bool
- func NVDECDecodes(l Limits, v VideoStream) bool
- func NVDECKey(v VideoStream) string
- func TooManyStreams(info MediaInfo) string
- func VAAPIDecodes(l Limits, v VideoStream) bool
- type AttachmentStream
- type AudioStream
- type Chapter
- type Container
- type Decoders
- type Disposition
- type EncodeResult
- type FormatInfo
- type HDRInfo
- type Hardware
- type Limits
- type Measurement
- type MediaInfo
- type NVDECSample
- type Progress
- type Rational
- type Report
- type SubtitleStream
- type Tier
- type VideoStream
Constants ¶
const MaxStreamsPerKind = mediainfo.MaxStreamsPerKind
MaxStreamsPerKind is the audio, and the subtitle, stream count at which a source is refused: pkg/mediainfo.MaxStreamsPerKind, the cap on the probe summary catalog stores (MediaInfo.Audio and .Subtitles, MaxItems=128). The transcode planner plans from that summary and the worker from a live probe of every stream, so past the cap the two would plan different streams, and a summary at the cap cannot say whether any were cut. A count of MaxStreamsPerKind or more reads the same in both -- the summary holds min(n, 128), which reaches 128 exactly when n does -- so refusing there is one decision, with one reason, on both sides.
Variables ¶
ErrDeviceUnavailable is an in-process encode whose GPU device could not be opened (no device mounted, a driver library missing): a fault of the node, not of the file, so the worker reports it as the class being unavailable rather than as a failed encode.
Functions ¶
func EightBitTarget ¶
func EightBitTarget(v VideoStream) bool
EightBitTarget reports whether v is encoded HEVC Main, 8-bit, rather than Main 10: SDR at 1080p or less (the owner's call, 2026-10-01). HDR10, HLG and Dolby Vision need 10 bits for their transfer at any size, and above 1080p the standard stays Main 10.
func NVDECDecodes ¶
func NVDECDecodes(l Limits, v VideoStream) bool
NVDECDecodes reports whether the NVENC tier decodes v on the GPU: the device's measured answer when l has one for v's format, else the static list.
func NVDECKey ¶
func NVDECKey(v VideoStream) string
NVDECKey is v's format as Decoders and the static list key it: the ffprobe codec name and the bit depth its pixel format carries, with ":444" for a 4:4:4 stream, or "" for any other chroma (4:2:2), which no key decodes. 4:4:4 has its key since 2026-11-03: the Arrow Lake on talos decodes HEVC 4:4:4 10-bit through VA-API at 9x, and the eleven 4:4:4 files of Chillin' in Another World would otherwise skip the GPU.
func TooManyStreams ¶
TooManyStreams is the refusal for a source at or past MaxStreamsPerKind of a kind, "" otherwise. It names the cap rather than the count, which the summary does not know past the cap, so the controller and the worker give the same reason.
func VAAPIDecodes ¶
func VAAPIDecodes(l Limits, v VideoStream) bool
VAAPIDecodes reports whether the QSV tier decodes v on the GPU, through VA-API, its frames mapped to QSV for vpp_qsv and the encoder (2026-10-16: the NUC decoded every x264 source in software and uploaded each frame, so the encoder's preset changed its encode time by under 6%). Only a format the pod measured decodes so -- the trial is the whole pipeline -- with no static list: Intel's decoders vary by generation, and a format the driver cannot decode falls back to software frames the hwmap cannot take.
Types ¶
type AttachmentStream ¶
AttachmentStream is one attachment (font, cover art, ...) of a MediaInfo.
type AudioStream ¶
type AudioStream struct {
Index int32
Codec, Profile string
Channels int32
ChannelLayout string
SampleRate int32
BitRateKbps int32
Lossless, Atmos bool
Language, Title string
Disposition Disposition
}
AudioStream is one audio stream of a MediaInfo.
type Container ¶
type Container string
Container is the output container format written by a transcode.
type Decoders ¶
Decoders are the source formats a device was measured to decode on NVDEC (ProbeDecoders), by NVDECKey. A format the trial could not test -- the node's ffmpeg has no encoder to make a sample of it -- is absent, and the static list decides it.
type Disposition ¶
type Disposition struct {
Default, Forced, Comment, HearingImpaired, VisualImpaired, Dub, Original bool
}
Disposition mirrors ffprobe's per-stream disposition flags this package cares about.
type EncodeResult ¶
type EncodeResult struct {
// LogTail is the end of FFmpeg's log, on a failure.
LogTail string
// SourceEndMillis is where the source's video and the audio the plan
// keeps end -- the last demuxed packet's timestamp plus its duration, in
// the output's timeline -- or 0 when the run did not measure it. It is
// the length Verify holds the output to: the source's container duration
// may be a dropped track's or a subtitle's (RoboCop's Turkish DTS 3.4 s
// past the video, The Mitchells vs. the Machines' SubRip cues 265 s past
// it, 2026-10-23 and -25), which no output can match.
SourceEndMillis int64
}
EncodeResult is what an engine's run reports besides its error: the tail of FFmpeg's log on a failure, and the end of the source as the run demuxed it.
type FormatInfo ¶
FormatInfo is the container-level detail of a MediaInfo.
type HDRInfo ¶
type HDRInfo struct {
Format commonv1.HdrFormat
MasteringDisplay *mediainfo.MasteringDisplay
ContentLight *mediainfo.ContentLight
DolbyVision *mediainfo.DoviRecord
HasHDR10Plus bool
}
HDRInfo carries a video stream's HDR classification and metadata, using pkg/mediainfo's real side-data types and the shared commonv1.HdrFormat vocabulary rather than a local placeholder copy of either.
type Limits ¶
type Limits struct {
NVDEC *Decoders `json:"nvdec,omitempty"`
VAAPI *Decoders `json:"vaapi,omitempty"`
VideoEngines int `json:"videoEngines,omitempty"`
}
Limits are what a pool pod measured of its device. NVDEC is what its decoder decodes; nil is unmeasured, and the static list decides. VAAPI is what an Intel device decodes through VA-API into the QSV encode (VAAPIDecodes); nil is unmeasured, and nothing is. VideoEngines is how many video (media) engines the device has, from the kernel's DRM fdinfo (pkg/transcode/drminfo): admission shares them between Plex's streams and clustarr's encodes; 0 is unmeasured, read as one.
type Measurement ¶
Measurement is what a pool pod measured of its own device: the tier its class encodes on there (Intel's QSV, else VAAPI) and the device's limits, NVDEC's decodable formats among them.
type MediaInfo ¶
type MediaInfo struct {
Path string
Format FormatInfo
Video []VideoStream
Audio []AudioStream
Subtitles []SubtitleStream
Attachments []AttachmentStream
Chapters []Chapter
Tags map[string]string
// OriginalLanguage is the file's item's original language (TMDB's,
// "ja"), "" when unknown: the standard's "original" (Profile.Languages).
// Not probed; the planner and the worker set it from the item.
OriginalLanguage string
// Languages are the languages the file is known to carry, as base tags
// ("ja", "en"): its MediaFile's spec.languages, which import froze from
// the tagged tracks and the grab's reading of the release. The standard
// names an untagged audio track by them (standard.nameUntagged). Not
// probed; the planner and the worker set it from the file's record.
Languages []string
// CropAspectMilli is the display aspect ratio, in thousandths, the
// file's picture is cropped to in its encode (1778 for 16:9, 1333 for
// 4:3): its series keeps another shape than the file's and crops
// (catalogv1alpha1.Series.CropTarget). Zero crops nothing. Not probed;
// the planner and the worker set it from the item.
CropAspectMilli int32
}
MediaInfo is pkg/transcode's own technical description of one media file: everything Plan needs to decide skip/remuxOnly/encode/reject and render an argv.
func FromProbe ¶
FromProbe builds Plan's input model from a pkg/mediainfo probe. mi supplies the CRD-level summary (bit depth, HDR classification, DV profile); raw supplies per-stream detail. Packets, which no probe supplies, stays zero.
It is the transcode worker's input. The detail it adds over FromSummary -- the source's own colour tags, HDR side data, levels, dispositions, chapters -- is kept for callers and diagnostics, but none of it reaches the argv: Plan renders colour from the HDR classification and never renders the side data, so a plan made here and one made by FromSummary from the stored summary of the same file render identically.
func FromSummary ¶
FromSummary builds Plan's input model from the probe summary alone -- the api/common/v1alpha1.MediaInfo that MediaFile.status.mediaInfo stores -- for the file at path. It is what the transcode planner plans from (the manager does not mount /data, so it cannot probe; Phase E ruling R3).
Everything Plan's DECISION and every argument Args renders is derivable from the summary, so a plan made here renders the same argv as one made through FromProbe from a live probe of the same bytes; that is the property TestFromSummaryAndFromProbeRenderTheSameArgs holds on a real file. The two things the summary lacks cannot change the argv: colour tags are rendered from the HDR classification ([hdrColour]), and HDR10 mastering display and content light levels are never rendered at all -- FFmpeg's libx265 wrapper carries them from the source's side data ([X265Params]). What it cannot supply stays zero: format tags (the caller adds CLUSTARR_PROFILE), size, per-stream level, field order and packet counts, and HDR side data.
Stream indexes are type-relative (0:a:N), as Plan expects, not the container-wide indexes the summary stores.
type NVDECSample ¶
type NVDECSample struct{ Key, Encoder, PixFmt string }
NVDECSample is one format the in-process measurement tries on NVDEC: its Decoders key and the software encoder and pixel format that make a sample of it.
func NVDECSampleFormats ¶
func NVDECSampleFormats() []NVDECSample
NVDECSampleFormats are the formats a device's NVDEC, or an Intel device's VA-API decoder, is measured on.
type Progress ¶
type Progress struct {
Frame int64
FPSMilli int32
SpeedMilli int32
OutTimeMillis int64
BitrateKbps int32
Percent int32
OutputBytes int64
}
Progress is an encode's progress in scaled ints -- FPSMilli, SpeedMilli, OutTimeMillis, Percent, BitrateKbps, OutputBytes -- with no float anywhere (CLAUDE.md); it feeds the 1 Hz schema.TranscodeProgress telemetry.
type Rational ¶
type Rational struct{ Num, Den int64 }
Rational is a plain numerator/denominator pair, used for frame rates ("24000/1001") without ever introducing a float.
type Report ¶
Report is an output's verification (engine.Verify): whether it matched the plan's expectation, and every way it did not.
type SubtitleStream ¶
type SubtitleStream struct {
Index int32
Codec string
Bitmap bool
Language, Title string
Disposition Disposition
}
SubtitleStream is one subtitle stream of a MediaInfo.
type VideoStream ¶
type VideoStream struct {
Index int32
Codec, Profile string
Level int32
PixFmt string
BitDepth int32
Width, Height int32
// DisplayAspectMilli is the picture's display aspect ratio in
// thousandths (the probe summary's displayAspectMilli, first video
// stream only): frame times sample aspect; 0 when unknown.
DisplayAspectMilli int32
BitRateKbps int32 // the probe summary's videoBitrateKbps, first video stream only
FrameRate Rational
FieldOrder string // "progressive"|"tt"|"bb"|"tb"|"bt"
ColorRange, ColorPrimaries, ColorTransfer, ColorSpace string
HDR HDRInfo
Packets int64
Duration time.Duration
Disposition Disposition
Language, Title string
// Encoder is the stream's ENCODER tag, the probe summary's videoEncoder
// (first video stream only): an FFmpeg HEVC or AV1 encoder there marks a
// source another tool transcoded (commonv1.MediaInfo.TranscodedElsewhere).
Encoder string
}
VideoStream is one video stream of a MediaInfo.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package donoraudio cuts an audio donor down to the tracks a graft needs (anime dual-audio spec §7.2; loop spec §4.12): the import agent reduces a donor at import, and the graft run reduces a donor imported before it did.
|
Package donoraudio cuts an audio donor down to the tracks a graft needs (anime dual-audio spec §7.2; loop spec §4.12): the import agent reduces a donor at import, and the graft run reduces a donor imported before it did. |
|
Package drminfo reads what the kernel's DRM driver says about a render node through the fdinfo of an open handle to it (Documentation/gpu/ drm-usage-stats.rst): the driver's name and how many video engines the device has, the capacity admission shares between Plex's streams and clustarr's encodes.
|
Package drminfo reads what the kernel's DRM driver says about a render node through the fdinfo of an open handle to it (Documentation/gpu/ drm-usage-stats.rst): the driver's name and how many video engines the device has, the capacity admission shares between Plex's streams and clustarr's encodes. |
|
Package engine runs a standard plan (pkg/transcode/standard) in-process on FFmpeg 9 through the ffgo fork: no ffmpeg subprocess.
|
Package engine runs a standard plan (pkg/transcode/standard) in-process on FFmpeg 9 through the ffgo fork: no ffmpeg subprocess. |
|
Package selfcheck proves a transcoder image can do its class's work: it loads FFmpeg 9 and the ffgo shim in-process (pkg/ffruntime), finds every encoder, muxer and filter the class needs by name, and encodes with the CPU encoders.
|
Package selfcheck proves a transcoder image can do its class's work: it loads FFmpeg 9 and the ffgo shim in-process (pkg/ffruntime), finds every encoder, muxer and filter the class needs by name, and encodes with the CPU encoders. |
|
Package standard decides transcode's fixed transcoding standard (spec docs/superpowers/specs/2026-09-30-ffgo-transcoding-design.md §1, its layout since Version 2 docs/superpowers/specs/2026-10-06-mp4-standard-design.md) for the in-process engine: one MP4 holding HEVC Main 10 at the source's resolution and frame rate, tagged hvc1; HDR10 and HLG kept; Dolby Vision stripped to its base layer, or skipped when it has none; per language a Dolby surround track (E-AC-3 or AC-3 copied, else AC-3 5.1) plus an AAC 2.0 companion, or AAC alone for mono or stereo; chapters and tags kept.
|
Package standard decides transcode's fixed transcoding standard (spec docs/superpowers/specs/2026-09-30-ffgo-transcoding-design.md §1, its layout since Version 2 docs/superpowers/specs/2026-10-06-mp4-standard-design.md) for the in-process engine: one MP4 holding HEVC Main 10 at the source's resolution and frame rate, tagged hvc1; HDR10 and HLG kept; Dolby Vision stripped to its base layer, or skipped when it has none; per language a Dolby surround track (E-AC-3 or AC-3 copied, else AC-3 5.1) plus an AAC 2.0 companion, or AAC alone for mono or stereo; chapters and tags kept. |