Documentation
¶
Overview ¶
Package transcoder manages a bounded pool of FFmpeg worker processes. Each stream may run one FFmpeg process per ladder rung (passthrough copy or ABR encode); all read the same raw ingest. GPU acceleration (NVENC) is used when configured on profiles / global HW.
Index ¶
- type Profile
- type ProfileSnapshot
- type RenditionTarget
- type RuntimeStatus
- type Service
- func (s *Service) RuntimeStatus(streamID domain.StreamCode) (RuntimeStatus, bool)
- func (s *Service) SetFatalCallback(fn func(streamCode domain.StreamCode))
- func (s *Service) Start(ctx context.Context, logStreamCode domain.StreamCode, ...) error
- func (s *Service) StartProfile(streamID domain.StreamCode, profileIndex int, target RenditionTarget) error
- func (s *Service) Stop(streamID domain.StreamCode)
- func (s *Service) StopProfile(streamID domain.StreamCode, profileIndex int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Profile ¶
type Profile struct {
Width int
Height int
Bitrate string // e.g. "4000k"
Codec string // e.g. "h264_nvenc", "libx264"
Preset string // e.g. "p5" (NVENC), "fast" (libx264)
CodecProfile string // H.264/HEVC profile (baseline, main, high)
CodecLevel string // e.g. 4.1
MaxBitrate int // kbps peak (0 = omit -maxrate)
Framerate float64
KeyframeInterval int // GOP target in seconds (0 = encoder default)
Bframes *int // nil = encoder default; 0 = explicit none
Refs *int // nil = encoder default
SAR string // "" = inherit; "N:M" sets output sample aspect ratio
ResizeMode string // "" = pad; "pad"|"crop"|"stretch"|"fit"
}
Profile defines a single transcoding output rendition. Rendition label in logs and URLs is track_<n> from ladder order (see buffer.VideoTrackSlug).
type ProfileSnapshot ¶ added in v0.0.8
type ProfileSnapshot struct {
Index int `json:"index"` // 0-based ladder index; track label = track_<index+1>
Track string `json:"track"`
RestartCount int `json:"restart_count"`
Errors []domain.ErrorEntry `json:"errors,omitempty"`
}
ProfileSnapshot is a serialisable copy of one profile encoder's runtime state. Errors is a bounded rolling history (newest first) of FFmpeg crash messages captured for this profile since the stream started.
type RenditionTarget ¶
type RenditionTarget struct {
BufferID domain.StreamCode
Profile Profile
}
RenditionTarget binds one encoded ladder rung to its Buffer Hub output slot.
type RuntimeStatus ¶ added in v0.0.8
type RuntimeStatus struct {
Profiles []ProfileSnapshot `json:"profiles"`
}
RuntimeStatus is a JSON-safe snapshot of transcoder state for one stream.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages the FFmpeg worker pool.
func (*Service) RuntimeStatus ¶ added in v0.0.8
func (s *Service) RuntimeStatus(streamID domain.StreamCode) (RuntimeStatus, bool)
RuntimeStatus returns a snapshot of per-profile encoder state. Returns ok=false if the stream has no transcoder pipeline running.
func (*Service) SetFatalCallback ¶
func (s *Service) SetFatalCallback(fn func(streamCode domain.StreamCode))
SetFatalCallback registers a function called when a transcoder profile exceeds its maximum restart count. The callback fires once per profile that gives up. It is safe to call this before or after Start.
func (*Service) Start ¶
func (s *Service) Start( ctx context.Context, logStreamCode domain.StreamCode, rawIngestID domain.StreamCode, tc *domain.TranscoderConfig, targets []RenditionTarget, ) error
Start launches one FFmpeg encoder per RenditionTarget (same raw ingest, different output buffers).
func (*Service) StartProfile ¶
func (s *Service) StartProfile(streamID domain.StreamCode, profileIndex int, target RenditionTarget) error
StartProfile starts a single FFmpeg encoder for one profile index on an existing stream worker.
func (*Service) Stop ¶
func (s *Service) Stop(streamID domain.StreamCode)
Stop cancels all FFmpeg encoders for a stream and waits for them to exit.
func (*Service) StopProfile ¶
func (s *Service) StopProfile(streamID domain.StreamCode, profileIndex int)
StopProfile stops a single FFmpeg encoder for one profile index.