Documentation
¶
Index ¶
- Constants
- Variables
- type Artwork
- type AudioProfile
- func (r AudioProfile) Codec() *Codec
- func (r AudioProfile) Insert(bind *pg.Bind) (string, error)
- func (r AudioProfile) Options() json.RawMessage
- func (r AudioProfile) Par() *ff.AVCodecParameters
- func (r *AudioProfile) Scan(row pg.Row) error
- func (r AudioProfile) String() string
- func (r AudioProfile) TimeBase() *ff.AVRational
- func (r AudioProfile) Type() CodecType
- func (r AudioProfile) UUID() uuid.UUID
- func (r *AudioProfile) UnmarshalJSON(data []byte) error
- func (r AudioProfile) Update(bind *pg.Bind) error
- type AudioProfileMeta
- type AudioProfileUUID
- type ChannelLayout
- type ChannelLayoutList
- type ChannelLayoutListRequest
- type Chapter
- type Codec
- type CodecGetRequest
- type CodecList
- type CodecListRequest
- type CodecMeta
- type CodecType
- type Device
- type DeviceList
- type DeviceListRequest
- type Duration
- type Format
- type FormatList
- type FormatListRequest
- type FormatMeta
- type FormatProfile
- type FormatProfileMeta
- type FormatProfileUUID
- type Metadata
- type Option
- func AudioOptionsForCodec(codec *ff.AVCodec) []Option
- func NewOption(ctx *ff.AVOption) Option
- func OptionsForCodec(codec *ff.AVCodec) []Option
- func OptionsForFormat(format *ff.AVOutputFormat) []Option
- func OptionsForInputFormat(format *ff.AVInputFormat) []Option
- func SubtitleOptionsForCodec(_ *ff.AVCodec) []Option
- func VideoOptionsForCodec(codec *ff.AVCodec) []Option
- type OptionConst
- type Output
- type OutputMeta
- type OutputUUID
- type PixelFormat
- type PixelFormatList
- type PixelFormatListRequest
- type Profile
- type ProfileMeta
- type ProfileMetaAudio
- type ProfileMetaStream
- type ProfileMetaVideo
- type SampleFormat
- type SampleFormatList
- type SampleFormatListRequest
- type StreamProfile
- func (r StreamProfile) Codec() *Codec
- func (r StreamProfile) Disposition() ff.AVDisposition
- func (r StreamProfile) Index() int
- func (r StreamProfile) MarshalJSON() ([]byte, error)
- func (r StreamProfile) Metadata() []gomedia.Metadata
- func (r StreamProfile) Options() json.RawMessage
- func (r StreamProfile) Par() *ff.AVCodecParameters
- func (r StreamProfile) String() string
- func (r StreamProfile) TimeBase() *ff.AVRational
- func (r StreamProfile) Type() CodecType
- func (r StreamProfile) UUID() uuid.UUID
- func (r *StreamProfile) UnmarshalJSON(data []byte) error
- type SubtitleProfile
- func (r SubtitleProfile) Codec() *Codec
- func (r SubtitleProfile) Options() json.RawMessage
- func (r SubtitleProfile) Par() *ff.AVCodecParameters
- func (r *SubtitleProfile) Scan(row pg.Row) error
- func (r SubtitleProfile) String() string
- func (r SubtitleProfile) TimeBase() *ff.AVRational
- func (r SubtitleProfile) Type() CodecType
- func (r SubtitleProfile) UUID() uuid.UUID
- func (r *SubtitleProfile) UnmarshalJSON(data []byte) error
- type SubtitleProfileMeta
- type SubtitleProfileUUID
- type VideoProfile
- func (r VideoProfile) Codec() *Codec
- func (r VideoProfile) Insert(bind *pg.Bind) (string, error)
- func (r VideoProfile) Options() json.RawMessage
- func (r VideoProfile) Par() *ff.AVCodecParameters
- func (r *VideoProfile) Scan(row pg.Row) error
- func (r VideoProfile) String() string
- func (r VideoProfile) TimeBase() *ff.AVRational
- func (r VideoProfile) Type() CodecType
- func (r VideoProfile) UUID() uuid.UUID
- func (r *VideoProfile) UnmarshalJSON(data []byte) error
- type VideoProfileMeta
- type VideoProfileUUID
Constants ¶
const ( // Audio options OptionAudioBitrate = "audio_bitrate" OptionAudioProfile = "audio_profile" OptionSampleRate = "sample_rate" OptionSampleFormat = "sample_format" OptionChannelLayout = "channel_layout" // Video options OptionVideoBitrate = "video_bitrate" OptionVideoProfile = "video_profile" OptionWidth = "width" OptionHeight = "height" OptionPixelFormat = "pixel_format" OptionFrameRate = "frame_rate" )
const (
DefaultSchema = "gomedia"
)
Variables ¶
var Objects string
var Queries string
Functions ¶
This section is empty.
Types ¶
type Artwork ¶
type Artwork struct {
Type string `json:"type,omitempty" help:"Artwork mimetype, e.g. \"image/jpeg\"." example:"image/jpeg"`
Width int `json:"width,omitempty" help:"Artwork width, in pixels." example:"600"`
Height int `json:"height,omitempty" help:"Artwork height, in pixels." example:"600"`
Data []byte `json:"data,omitempty" help:"Raw artwork image data."`
}
Artwork is a JSON-friendly view of a gomedia.Metadata entry holding embedded artwork (cover art, thumbnail, ...) - the binary payload Metadata omits, decoded far enough to report its mimetype and pixel dimensions.
func NewArtwork ¶
NewArtwork converts a gomedia.Metadata entry holding artwork (see gomedia.MetaArtwork) into the JSON-friendly Artwork shape. Value() is used for Type since, per gomedia.Metadata's contract, it returns the mimetype when the underlying value is a byte slice. Width/Height are read from Image(), which is nil (leaving both zero) if the data can't be decoded as an image.
func NewArtworkList ¶
NewArtworkList converts gomedia.Metadata entries holding artwork (see gomedia.MetaArtwork) to the JSON-friendly Artwork shape, one per entry - e.g. an audio file with multiple attached-pic streams (cover, cover-2, ...).
type AudioProfile ¶
type AudioProfile struct {
Id uuid.UUID `json:"id,omitempty"` // Unique identifier for the audio profile
Name string `json:"codec" arg:"" required:""` // "aac", "libmp3lame", "copy", ...
AudioProfileMeta
}
func NewAudioProfile ¶
func NewAudioProfile(codec string) (*AudioProfile, error)
func (AudioProfile) Codec ¶
func (r AudioProfile) Codec() *Codec
func (AudioProfile) Insert ¶ added in v1.9.3
func (r AudioProfile) Insert(bind *pg.Bind) (string, error)
Insert binds values and returns the insert (or, if Id is set, upsert) query for an audio profile row. Id is set when seeding a profile with a deterministic id (see profile/manager's seed loader and schema.SeedUUID); a normal create leaves the database to generate one.
func (AudioProfile) Options ¶
func (r AudioProfile) Options() json.RawMessage
func (AudioProfile) Par ¶
func (r AudioProfile) Par() *ff.AVCodecParameters
func (*AudioProfile) Scan ¶
func (r *AudioProfile) Scan(row pg.Row) error
Expected column order: id, codec, bitrate, profile, sample_rate, sample_format, channel_layout, opts.
func (AudioProfile) String ¶
func (r AudioProfile) String() string
func (AudioProfile) TimeBase ¶
func (r AudioProfile) TimeBase() *ff.AVRational
func (AudioProfile) Type ¶
func (r AudioProfile) Type() CodecType
func (AudioProfile) UUID ¶
func (r AudioProfile) UUID() uuid.UUID
func (*AudioProfile) UnmarshalJSON ¶ added in v1.9.3
func (r *AudioProfile) UnmarshalJSON(data []byte) error
UnmarshalJSON is required because codec/par/timebase/opts are unexported (see NewAudioProfile) - without it, a client decoding an AudioProfile from JSON would get one with a valid Name but a nil codec, which panics the first time it's used (e.g. writer.WithProfile). Resolves the codec from the decoded Name, exactly as NewAudioProfile does, then rebuilds par from whichever exported fields (Bitrate, SampleRate, ...) were decoded.
type AudioProfileMeta ¶
type AudioProfileMeta struct {
ProfileMetaAudio
Opts json.RawMessage `json:"options,omitempty"` // Additional codec options
// contains filtered or unexported fields
}
type AudioProfileUUID ¶
type ChannelLayout ¶
type ChannelLayout struct {
Name string `json:"name" help:"Channel layout name." example:"5.1"`
NumChannels int `json:"num_channels" help:"Number of channels." example:"6"`
// contains filtered or unexported fields
}
func NewChannelLayout ¶
func NewChannelLayout(ch *ff.AVChannelLayout) *ChannelLayout
func (ChannelLayout) Cell ¶
func (r ChannelLayout) Cell(col int) string
func (ChannelLayout) Context ¶
func (r ChannelLayout) Context() *ff.AVChannelLayout
Context returns the underlying FFmpeg channel layout constant.
func (ChannelLayout) Header ¶
func (ChannelLayout) Header() []string
func (ChannelLayout) String ¶
func (r ChannelLayout) String() string
func (ChannelLayout) Width ¶
func (ChannelLayout) Width(col int) int
type ChannelLayoutList ¶
type ChannelLayoutList []ChannelLayout
func (ChannelLayoutList) String ¶
func (r ChannelLayoutList) String() string
type ChannelLayoutListRequest ¶
type ChannelLayoutListRequest struct {
Name *string `json:"name,omitempty" help:"Filter by channel layout name." placeholder:"5.1" example:"5.1"`
NumChannels *uint64 `json:"num_channels,omitempty" help:"Filter by number of channels." placeholder:"6" example:"6"`
}
func (ChannelLayoutListRequest) Query ¶
func (r ChannelLayoutListRequest) Query() url.Values
type Chapter ¶
type Chapter struct {
Start Duration `json:"start" help:"Chapter start time, as a duration string (e.g. \"1h2m3.5s\")." example:"1m30s"`
End Duration `json:"end,omitempty" help:"Chapter end time, as a duration string." example:"3m45s"`
Metadata []Metadata `json:"metadata,omitempty" help:"Chapter tags, e.g. \"title\"."`
}
Chapter is a JSON-friendly view of a gomedia.Chapter - a single chapter marker's position in the container plus its own metadata tags (usually just "title").
func NewChapter ¶
NewChapter converts a gomedia.Chapter into the JSON-friendly Chapter shape. Tags are sorted by key for deterministic output, since a gomedia.Chapter's Metadata is a map and iteration order isn't stable.
func NewChapterList ¶
NewChapterList converts gomedia.Metadata entries holding chapter markers (see gomedia.MetaChapter) to the JSON-friendly Chapter shape, one per entry, in the same order the chapters appear in the container.
type Codec ¶
type Codec struct {
CodecMeta
IsEncoder bool `json:"is_encoder"` // Whether this codec can encode
IsDecoder bool `json:"is_decoder"` // Whether this codec can decode
IsHardware bool `json:"is_hardware,omitempty"` // Whether this codec is hardware-accelerated
Opts []Option `json:"opts,omitempty"` // Codec options
// contains filtered or unexported fields
}
type CodecGetRequest ¶
type CodecGetRequest struct {
IsEncoder *bool `json:"is_encoder,omitempty"` // Prefer an encoder (true) or decoder (false); tries an encoder then a decoder if omitted
}
func (CodecGetRequest) Query ¶
func (r CodecGetRequest) Query() url.Values
type CodecList ¶
type CodecList struct {
CodecListRequest
Count uint64 `json:"count"` // Number of codecs
Body []*Codec `json:"body,omitempty"` // List of codecs
}
type CodecListRequest ¶
type CodecListRequest struct {
Type *CodecType `json:"type,omitempty" enum:"audio,video,subtitle"` // Codec type to filter codecs by; "audio", "video", "subtitle"
IsEncoder *bool `json:"is_encoder,omitempty"` // Filter by encoder capability; both encoders and decoders are returned if omitted
IsDecoder *bool `json:"is_decoder,omitempty"` // Filter by decoder capability; both encoders and decoders are returned if omitted
IsHardware *bool `json:"is_hardware,omitempty"` // Filter by hardware acceleration; both hardware and software codecs are returned if omitted
pg.OffsetLimit
}
func (CodecListRequest) Query ¶
func (r CodecListRequest) Query() url.Values
type CodecMeta ¶
type CodecMeta struct {
Name string `json:"name"` // Codec name, e.g. "aac", "libmp3lame", "copy", ...
Description string `json:"description,omitempty"` // Codec description
Type CodecType `json:"type"` // Codec type; "audio", "video", "subtitle"
}
CodecMeta identifies a codec - its name, human-readable description, and media type - independent of its encode/decode capability or options.
type CodecType ¶
type CodecType ff.AVMediaType
func (CodecType) MarshalJSON ¶
func (*CodecType) UnmarshalJSON ¶
func (*CodecType) UnmarshalText ¶
type Device ¶
type Device struct {
Format string `json:"format" help:"Device format (driver) name." example:"avfoundation"`
Index int `json:"index" help:"Device index within its format." example:"0"`
Name string `json:"name" help:"Device name." example:"Built-in Microphone"`
Description string `json:"description,omitempty" help:"Device description." example:"Built-in Microphone"`
IsDefault bool `json:"is_default,omitempty" help:"Whether this is the default device for its format." example:"true"`
IsInput bool `json:"is_input" help:"Whether this device can be used as an input." example:"true"`
IsOutput bool `json:"is_output" help:"Whether this device can be used as an output." example:"false"`
MediaTypes []string `json:"media_types,omitempty" help:"Media types supported by this device." example:"[\"audio\"]"`
}
type DeviceList ¶
type DeviceList []Device
func (DeviceList) String ¶
func (r DeviceList) String() string
type DeviceListRequest ¶
type DeviceListRequest struct {
Name *string `json:"name,omitempty" help:"Filter by device name." placeholder:"Built-in Microphone" example:"Built-in Microphone"`
Format *string `json:"format,omitempty" help:"Filter by device format name." placeholder:"avfoundation" example:"avfoundation"`
IsInput *bool `json:"is_input,omitempty" help:"Filter by input capability." example:"true"`
IsOutput *bool `json:"is_output,omitempty" help:"Filter by output capability." example:"false"`
}
func (DeviceListRequest) Query ¶
func (r DeviceListRequest) Query() url.Values
type Duration ¶
Duration is a time.Duration that marshals to/from its String() form (e.g. "1h2m3s") in JSON, rather than time.Duration's default of a raw count of nanoseconds.
func (Duration) MarshalJSON ¶
func (*Duration) UnmarshalJSON ¶
type Format ¶
type Format struct {
FormatMeta
IsInput bool `json:"is_input,omitempty" help:"Whether this format can be used as an input (demuxer)." example:"true"`
IsOutput bool `json:"is_output,omitempty" help:"Whether this format can be used as an output (muxer)." example:"false"`
Opts []Option `json:"opts,omitempty" help:"Format-specific options."`
Audio []string `json:"audio,omitempty" help:"Audio codecs supported by this format; the first is the default." example:"[\"aac\"]"`
Video []string `json:"video,omitempty" help:"Video codecs supported by this format; the first is the default." example:"[\"h264\"]"`
Subtitle []string `json:"subtitle,omitempty" help:"Subtitle codecs supported by this format; the first is the default." example:"[\"mov_text\"]"`
}
Format is an output (muxer) format - or an input (demuxer) format, sharing the same shape with Audio/Video/Subtitle left empty, so both can appear together in a FormatList.
func NewInputFormat ¶
func NewInputFormat(format *ff.AVInputFormat) *Format
NewInputFormat builds a Format from an input (demuxer) format. Unlike NewOutputFormat, there's no meaningful Audio/Video/Subtitle codec list to populate - "default codec to encode with" is an output-format concept a demuxer doesn't have - so those fields are left empty.
func NewOutputFormat ¶
func NewOutputFormat(format *ff.AVOutputFormat) *Format
type FormatList ¶
type FormatList struct {
FormatListRequest
Count uint64 `json:"count" help:"Number of formats." example:"1"`
Body []*Format `json:"body,omitempty" help:"List of formats."`
}
func (FormatList) String ¶
func (r FormatList) String() string
type FormatListRequest ¶
type FormatListRequest struct {
Name *string `json:"name,omitempty" help:"Filter by format name." placeholder:"mp4" example:"mp4"`
Type *string `json:"type,omitempty" help:"Filter by MIME content type." placeholder:"video/mp4" example:"video/mp4"`
Ext *string `json:"ext,omitempty" help:"Filter by file extension." placeholder:"mp4" example:"mp4"`
IsInput *bool `json:"is_input,omitempty" help:"Filter by input capability." example:"true"`
IsOutput *bool `json:"is_output,omitempty" help:"Filter by output capability." example:"false"`
pg.OffsetLimit
}
func (FormatListRequest) Query ¶
func (r FormatListRequest) Query() url.Values
type FormatMeta ¶
type FormatMeta struct {
Name string `json:"name" help:"Format name." example:"mp4"`
Description string `json:"description,omitempty" help:"Human-readable format description." example:"MP4 (MPEG-4 Part 14)"`
Type string `json:"type,omitempty" help:"MIME content type." example:"video/mp4"`
Ext string `json:"ext,omitempty" help:"File extensions associated with this format." example:"mp4,m4a,m4v"`
}
FormatMeta identifies a format - its name, human-readable description, MIME type, and file extensions - independent of whether it's usable as an input, an output, or what codecs it supports. This is the subset of Format fit to embed in output that isn't specifically about container format capabilities, e.g. ProbeResponse.
type FormatProfile ¶ added in v1.9.3
type FormatProfile struct {
Id uuid.UUID `json:"id,omitempty"` // Unique identifier for the format profile
FormatProfileMeta
}
func (FormatProfile) Insert ¶ added in v1.9.3
func (r FormatProfile) Insert(bind *pg.Bind) (string, error)
Insert binds values and returns the insert (or, if Id is set, upsert) query for a format profile row. Id is set when seeding a profile with a deterministic id (see profile/manager's seed loader and schema.SeedUUID); a normal create leaves the database to generate one.
func (*FormatProfile) Scan ¶ added in v1.9.3
func (r *FormatProfile) Scan(row pg.Row) error
Expected column order: id, name, description, opts.
func (FormatProfile) String ¶ added in v1.9.3
func (r FormatProfile) String() string
type FormatProfileMeta ¶ added in v1.9.3
type FormatProfileMeta struct {
Name string `json:"name" arg:"" required:""` // "hls-vod", "dash-vod", ...
Description *string `json:"description,omitempty"`
Opts json.RawMessage `json:"options,omitempty"` // Format-specific options, e.g. {"hls_time": 4}
}
FormatProfileMeta holds a named, reusable bundle of output-format-level settings - e.g. HLS/DASH segmenting - as opposed to Audio/Video/ SubtitleProfile, which each configure a single codec. There's no ffmpeg encoder to resolve Name against here (unlike those): the settings that matter (segment duration, playlist type, ...) are muxer/protocol options, so they all flow through Opts, keyed however the consumer (e.g. an encoder task) expects. Distinct from Format/FormatMeta (see format.go), which describe an ffmpeg-registered muxer/demuxer itself, not a database-persisted, user-defined bundle of settings.
type FormatProfileUUID ¶ added in v1.9.3
type Metadata ¶
type Metadata struct {
Key string `json:"key" help:"Metadata tag name, e.g. \"title\", \"artist\", \"language\"." example:"title"`
Value string `json:"value,omitempty" help:"Metadata tag value." example:"Sample Track"`
Any any `json:"any,omitempty" help:"Metadata tag value, as a JSON-friendly type (string, number, bool, array, or object)."`
}
Metadata is a JSON-friendly key/value view of a gomedia.Metadata entry - binary payloads (e.g. artwork) aren't represented here.
func NewMetadata ¶
NewMetadata builds a Metadata entry from a key and an arbitrary value. Value is always a display-friendly string - the value itself, if it's already a string, or its fmt.Sprint representation otherwise. Any additionally carries the original value when it wasn't already a plain string, so JSON-friendly types (numbers, bools, slices, objects) survive round-tripping instead of being flattened to their string form.
func NewMetadataList ¶
NewMetadataList converts gomedia.Metadata entries (an interface - which encoding/json can marshal but never unmarshal, having no concrete type to instantiate) to the JSON-friendly, round-trippable Metadata shape. Used both for StreamProfile's per-stream metadata and for container-level metadata elsewhere (e.g. task.ProbeResponse).
func (Metadata) MarshalJSON ¶
MarshalJSON omits Any from the output when it's redundant with Value - e.g. a metadata handler whose stored value is already a plain string, so Any() and Value() return the exact same thing. Any exists to carry richer JSON-friendly types (numbers, bools, slices, objects) beyond what the display string can hold; showing both when Any adds nothing over Value is just noise.
type Option ¶
type Option struct {
Name string `json:"name,omitempty" help:"Option name." example:"b"`
Description string `json:"description,omitempty" help:"Human-readable option description." example:"Set bitrate in bits/s."`
Type string `` /* 234-byte string literal not displayed */
Default any `json:"default,omitempty" help:"Default value." example:"128000"`
Const []OptionConst `json:"const,omitempty" help:"Fixed set of allowed values, if this option only accepts specific values."`
Min any `json:"min,omitempty" help:"Minimum allowed value, if applicable." example:"0"`
Max any `json:"max,omitempty" help:"Maximum allowed value, if applicable." example:"192000"`
Unit string `json:"unit,omitempty" help:"Unit the value is expressed in, if applicable." example:"bps"`
}
func AudioOptionsForCodec ¶
func OptionsForCodec ¶
func OptionsForFormat ¶
func OptionsForFormat(format *ff.AVOutputFormat) []Option
func OptionsForInputFormat ¶
func OptionsForInputFormat(format *ff.AVInputFormat) []Option
func SubtitleOptionsForCodec ¶
func VideoOptionsForCodec ¶
type OptionConst ¶
type OptionConst struct {
Name string `json:"name,omitempty" help:"Symbolic name for this value, if any." example:"fast"`
Description string `json:"description,omitempty" help:"Human-readable description of this value."`
Type string `` /* 227-byte string literal not displayed */
Default any `json:"default,omitempty" help:"The underlying value." example:"1"`
Min any `json:"min,omitempty" help:"Minimum allowed value, if applicable."`
Max any `json:"max,omitempty" help:"Maximum allowed value, if applicable."`
Unit string `json:"unit,omitempty" help:"Unit the value is expressed in, if applicable."`
}
OptionConst describes one of an Option's fixed set of allowed values (an AV_OPT_TYPE_CONST entry, or a hand-built constant like a supported sample rate, pixel format or codec profile). It's a separate, non-recursive type from Option - rather than reusing Option itself - because a const entry is always terminal: it never has its own set of constants. Option.Const being []Option would make Option a self-referential type, which the JSONSchema generator can't represent.
func NewOptionConst ¶
func NewOptionConst(ctx *ff.AVOption) OptionConst
NewOptionConst builds a terminal OptionConst (e.g. an AV_OPT_TYPE_CONST entry) from an FFmpeg option. Use this instead of NewOption when building an Option's Const list.
type Output ¶
type Output struct {
Id uuid.UUID `json:"id,omitempty"` // Unique identifier for the format profile
Format string `json:"format"` // Format name, e.g. "mp4", "mkv", "flv", ...
OutputMeta
}
func OutputWithName ¶
func OutputWithType ¶
func (*Output) UnmarshalJSON ¶ added in v1.9.3
UnmarshalJSON is required because ctx is unexported (see OutputWithName) - without it, a client decoding an Output from JSON would get one with a valid Format but a nil Context(), which every consumer (e.g. writer.Create) treats as "no such format". Resolves ctx from the decoded Format, exactly as OutputWithName does.
type OutputMeta ¶
type OutputMeta struct {
Description string `json:"description,omitempty"` // Format description
Opts json.RawMessage `json:"options,omitempty"` // Additional format options
// contains filtered or unexported fields
}
func (*OutputMeta) Context ¶
func (o *OutputMeta) Context() *ff.AVOutputFormat
type OutputUUID ¶
type PixelFormat ¶
type PixelFormat struct {
Name string `json:"name" help:"Pixel format name." example:"yuv420p"`
NumPlanes int `json:"num_planes" help:"Number of image planes." example:"3"`
BitDepth int `json:"bit_depth" help:"Bits per pixel." example:"12"`
IsPlanar bool `json:"is_planar" help:"Whether planes are stored separately rather than interleaved." example:"true"`
IsRGB bool `json:"is_rgb" help:"Whether the format is RGB, rather than YUV." example:"false"`
HasAlpha bool `json:"has_alpha" help:"Whether the format includes an alpha channel." example:"false"`
IsHWAccel bool `json:"is_hwaccel" help:"Whether this is a hardware-acceleration surface with no accessible pixel data." example:"false"`
IsFloat bool `json:"is_float" help:"Whether samples are floating point, rather than integer." example:"false"`
IsBigEndian bool `json:"is_bigendian" help:"Whether multi-byte samples are stored big-endian." example:"false"`
// contains filtered or unexported fields
}
func NewPixelFormat ¶
func NewPixelFormat(pixfmt ff.AVPixelFormat) *PixelFormat
func (PixelFormat) Cell ¶
func (r PixelFormat) Cell(col int) string
func (PixelFormat) Context ¶
func (r PixelFormat) Context() ff.AVPixelFormat
Context returns the underlying FFmpeg pixel format constant.
func (PixelFormat) Flags ¶
func (r PixelFormat) Flags() string
func (PixelFormat) Header ¶
func (PixelFormat) Header() []string
func (PixelFormat) String ¶
func (r PixelFormat) String() string
func (PixelFormat) Width ¶
func (PixelFormat) Width(col int) int
type PixelFormatList ¶
type PixelFormatList []PixelFormat
func (PixelFormatList) String ¶
func (r PixelFormatList) String() string
type PixelFormatListRequest ¶
type PixelFormatListRequest struct {
Name *string `json:"name,omitempty" help:"Filter by pixel format name." placeholder:"yuv420p" example:"yuv420p"`
NumPlanes *uint64 `json:"num_planes,omitempty" help:"Filter by number of planes." placeholder:"3" example:"3"`
}
func (PixelFormatListRequest) Query ¶
func (r PixelFormatListRequest) Query() url.Values
type Profile ¶
type Profile interface {
UUID() uuid.UUID // Unique identifier for this profile
Type() CodecType // Type for this profile
Codec() *Codec // Codec for this profile
Par() *ff.AVCodecParameters // Codec parameters for this profile
TimeBase() *ff.AVRational // Time base for this profile
Options() json.RawMessage // Additional codec-specific options
}
type ProfileMeta ¶
type ProfileMeta struct {
UUID uuid.UUID `json:"id,omitzero"`
Type CodecType `json:"type"`
Codec *CodecMeta `json:"codec,omitempty"`
Options json.RawMessage `json:"options,omitempty"`
*ProfileMetaAudio
*ProfileMetaVideo
*ProfileMetaStream
}
ProfileMeta is a JSON representation of a Profile, uniform across AudioProfile, VideoProfile, SubtitleProfile, and StreamProfile. Audio/Video carry their type-specific fields; Subtitle has none beyond Options, which is already common to every profile type. A StreamProfile additionally carries Stream, describing the demuxed stream itself rather than its codec configuration.
func NewProfileMeta ¶
func NewProfileMeta(p Profile) *ProfileMeta
NewProfileMeta builds a JSON representation of any Profile implementation.
type ProfileMetaAudio ¶
type ProfileMetaAudio struct {
Bitrate *uint64 `json:"audio_bitrate,omitempty"` // bps
Profile *string `json:"audio_profile,omitempty"` // Codec profile; "LC", "HE-AAC", ...
SampleRate *uint64 `json:"sample_rate,omitempty"` // Hz
SampleFormat *string `json:"sample_format,omitempty"` // Audio sample format; "fltp", "s16"
ChannelLayout *string `json:"channel_layout,omitempty"` // Audio channel layout; "mono", "stereo"
}
ProfileMetaAudio holds the audio-specific fields of a ProfileMeta - the canonical definition of "audio encoding parameters", embedded both here (for StreamProfile, whose values are derived from demuxed codec parameters) and in AudioProfileMeta (whose values are user-configured), so the two can't drift out of sync with each other.
type ProfileMetaStream ¶
type ProfileMetaStream struct {
Index int `json:"index"`
Disposition ff.AVDisposition `json:"disposition,omitempty"`
TimeBase *ff.AVRational `json:"timebase,omitempty"`
Metadata []Metadata `json:"metadata,omitempty"`
}
ProfileMetaStream holds the fields specific to a stream already discovered in a media file - as opposed to a codec configuration to encode with - so it's only populated for a StreamProfile.
type ProfileMetaVideo ¶
type ProfileMetaVideo struct {
Bitrate *uint64 `json:"video_bitrate,omitempty"` // bps
Profile *string `json:"video_profile,omitempty"` // Codec profile; "high", "main", "baseline"
Width *uint64 `json:"width,omitempty"` // Frame width in pixels
Height *uint64 `json:"height,omitempty"` // Frame height in pixels
PixelFormat *string `json:"pixel_format,omitempty"` // Video pixel format; "yuv420p", "nv12"
FrameRate *float64 `json:"frame_rate,omitempty"` // Frames per second
}
ProfileMetaVideo holds the video-specific fields of a ProfileMeta - see ProfileMetaAudio's doc comment; VideoProfileMeta embeds this the same way.
type SampleFormat ¶
type SampleFormat struct {
Name string `json:"name" help:"Sample format name." example:"fltp"`
ByteDepth int `json:"byte_depth" help:"Bytes per sample." example:"4"`
IsPlanar bool `json:"is_planar" help:"Whether planes are stored separately rather than interleaved." example:"true"`
// contains filtered or unexported fields
}
func NewSampleFormat ¶
func NewSampleFormat(samplefmt ff.AVSampleFormat) *SampleFormat
func (SampleFormat) Cell ¶
func (r SampleFormat) Cell(col int) string
func (SampleFormat) Context ¶
func (r SampleFormat) Context() ff.AVSampleFormat
Context returns the underlying FFmpeg sample format constant.
func (SampleFormat) Header ¶
func (SampleFormat) Header() []string
func (SampleFormat) String ¶
func (r SampleFormat) String() string
func (SampleFormat) Width ¶
func (SampleFormat) Width(col int) int
type SampleFormatList ¶
type SampleFormatList []SampleFormat
func (SampleFormatList) String ¶
func (r SampleFormatList) String() string
type SampleFormatListRequest ¶
type SampleFormatListRequest struct {
Name *string `json:"name"`
IsPlanar *bool `json:"is_planar,omitempty"`
}
func (SampleFormatListRequest) Query ¶
func (r SampleFormatListRequest) Query() url.Values
type StreamProfile ¶
type StreamProfile struct {
// contains filtered or unexported fields
}
StreamProfile describes a stream already discovered in an opened media file (via a Reader), rather than a codec configuration to encode with. Unlike AudioProfile/VideoProfile/SubtitleProfile, there is nothing here to validate or assemble: the underlying AVCodecParameters were already fully populated by the demuxer, so StreamProfile just wraps them.
A StreamProfile is valid only while the Reader it came from remains open: Par() aliases the AVCodecParameters extradata (SPS/PPS, OpusHead, ...) owned by the underlying AVFormatContext, and Codec() the AVCodec found for its codec ID. This is not a limitation in practice — the typical use (e.g. feeding writer.WithProfile for a remux) requires the source Reader to stay open anyway, since packets still need to be read from it.
func NewStreamProfile ¶
func NewStreamProfile(stream *ff.AVStream) (*StreamProfile, error)
NewStreamProfile describes an existing AVStream (typically obtained from an opened reader.Reader) as a Profile - audio, video, subtitle, data and attachment streams alike, so a caller remuxing a whole container doesn't silently drop any of them. Returns an error for attached-pic streams (cover art, already surfaced separately via Reader.Metadata's "artwork" key), since representing it as a stream too would duplicate that.
func (StreamProfile) Codec ¶
func (r StreamProfile) Codec() *Codec
Codec is nil if no decoder is registered for this codec in the current build. Par/TimeBase/Type remain valid either way.
func (StreamProfile) Disposition ¶
func (r StreamProfile) Disposition() ff.AVDisposition
Disposition returns the stream's disposition flags (default, forced, attached pic, ...).
func (StreamProfile) Index ¶
func (r StreamProfile) Index() int
Index returns the stream's index within its container, e.g. for Seek.
func (StreamProfile) MarshalJSON ¶
func (r StreamProfile) MarshalJSON() ([]byte, error)
MarshalJSON is required because every field of StreamProfile is unexported (see the type's doc comment) - without it, encoding/json has nothing to marshal and every stream serializes as "{}". ProfileMeta is built from the Profile interface, which StreamProfile fully implements.
func (StreamProfile) Metadata ¶
func (r StreamProfile) Metadata() []gomedia.Metadata
Metadata returns the stream's own tags — e.g. "language" (ISO 639-2, such as "eng"), "title", "handler_name" — as opposed to Reader.Metadata, which returns container-level tags. Unlike WithProfile's Options, this is read-only: there is no way to set per-stream metadata via a Profile.
func (StreamProfile) Options ¶
func (r StreamProfile) Options() json.RawMessage
Options is always nil: there is nothing to configure on a stream that's already been demuxed.
func (StreamProfile) Par ¶
func (r StreamProfile) Par() *ff.AVCodecParameters
func (StreamProfile) String ¶
func (r StreamProfile) String() string
func (StreamProfile) TimeBase ¶
func (r StreamProfile) TimeBase() *ff.AVRational
func (StreamProfile) Type ¶
func (r StreamProfile) Type() CodecType
Type is read directly from the stream's codec parameters, so it's always available even if no decoder is registered for the codec.
func (StreamProfile) UUID ¶
func (r StreamProfile) UUID() uuid.UUID
UUID is always the zero value: a StreamProfile describes a stream discovered in a file, not a persisted, identifiable configuration.
func (*StreamProfile) UnmarshalJSON ¶
func (r *StreamProfile) UnmarshalJSON(data []byte) error
UnmarshalJSON is the counterpart to MarshalJSON - without it, a client decoding a StreamProfile from JSON would silently get a zero-value struct (every field is unexported, so encoding/json has nothing to write into) that then re-marshals as bogus data (e.g. a zero AVCodecParameters, whose zero-valued codec_type of 0 happens to collide with AVMEDIA_TYPE_VIDEO).
codec is resolved from CodecMeta's own name, which round-trips exactly (unlike a codec ID's generic name, which can differ from its default decoder's own registered name - e.g. ID "mp3"'s default decoder is "mp3float"; see AVCodecID.UnmarshalJSON). par is then rebuilt field by field from whichever of ProfileMetaAudio/ProfileMetaVideo is present, since ProfileMeta no longer carries a raw AVCodecParameters.
type SubtitleProfile ¶
type SubtitleProfile struct {
Id uuid.UUID `json:"id,omitempty"` // Unique identifier for the subtitle profile
SubtitleProfileMeta
}
func NewSubtitleProfile ¶
func NewSubtitleProfile(codec string) (*SubtitleProfile, error)
func (SubtitleProfile) Codec ¶
func (r SubtitleProfile) Codec() *Codec
func (SubtitleProfile) Options ¶
func (r SubtitleProfile) Options() json.RawMessage
func (SubtitleProfile) Par ¶
func (r SubtitleProfile) Par() *ff.AVCodecParameters
func (*SubtitleProfile) Scan ¶
func (r *SubtitleProfile) Scan(row pg.Row) error
Expected column order: id, codec, opts.
func (SubtitleProfile) String ¶
func (r SubtitleProfile) String() string
func (SubtitleProfile) TimeBase ¶
func (r SubtitleProfile) TimeBase() *ff.AVRational
TimeBase always returns nil: unlike audio (sample rate) or video (frame rate), subtitle codecs have no rate-like field to derive one from, so the muxer/stream default applies.
func (SubtitleProfile) Type ¶
func (r SubtitleProfile) Type() CodecType
func (SubtitleProfile) UUID ¶
func (r SubtitleProfile) UUID() uuid.UUID
func (*SubtitleProfile) UnmarshalJSON ¶ added in v1.9.3
func (r *SubtitleProfile) UnmarshalJSON(data []byte) error
UnmarshalJSON is required because codec/par/opts are unexported (see NewSubtitleProfile) - without it, a client decoding a SubtitleProfile from JSON would get one with a valid Name but a nil codec, which panics the first time it's used (e.g. writer.WithProfile). Resolves the codec from the decoded Name, exactly as NewSubtitleProfile does.
type SubtitleProfileMeta ¶
type SubtitleProfileMeta struct {
Name string `json:"codec" arg:"" required:""` // "srt", "ass", "webvtt", "mov_text", "copy", ...
Opts json.RawMessage `json:"options,omitempty"` // Additional codec options
// contains filtered or unexported fields
}
SubtitleProfileMeta is deliberately minimal compared to Audio/VideoProfileMeta: subtitle codecs have no universal structural parameter analogous to audio's sample rate or video's width/height/frame rate — every sampled encoder (srt, ass, webvtt, mov_text, dvbsub, dvdsub) declares neither a static profile list nor any shared option. Codec-specific knobs (mov_text's "height", dvbsub's "min_bpp", dvdsub's "palette") flow through Opts like any other private codec option, the same as x264's crf/preset.
func (SubtitleProfileMeta) Insert ¶
func (r SubtitleProfileMeta) Insert(bind *pg.Bind) (string, error)
Insert binds values and returns the insert query for a subtitle profile row.
func (*SubtitleProfileMeta) Set ¶
func (r *SubtitleProfileMeta) Set(name string, value any) error
Set a subtitle profile option. Every subtitle option is codec-specific (there's no universal field like bitrate or width), so this only ever touches the generic Opts dict. If value is nil, the option is removed.
type SubtitleProfileUUID ¶
type VideoProfile ¶
type VideoProfile struct {
Id uuid.UUID `json:"id,omitempty"` // Unique identifier for the video profile
VideoProfileMeta
}
func NewVideoProfile ¶
func NewVideoProfile(codec string) (*VideoProfile, error)
func (VideoProfile) Codec ¶
func (r VideoProfile) Codec() *Codec
func (VideoProfile) Insert ¶ added in v1.9.3
func (r VideoProfile) Insert(bind *pg.Bind) (string, error)
Insert binds values and returns the insert (or, if Id is set, upsert) query for a video profile row. Id is set when seeding a profile with a deterministic id (see profile/manager's seed loader and schema.SeedUUID); a normal create leaves the database to generate one. Defined on VideoProfile (rather than relying on VideoProfileMeta.Insert below) since only the outer type has access to Id.
func (VideoProfile) Options ¶
func (r VideoProfile) Options() json.RawMessage
func (VideoProfile) Par ¶
func (r VideoProfile) Par() *ff.AVCodecParameters
func (*VideoProfile) Scan ¶
func (r *VideoProfile) Scan(row pg.Row) error
Expected column order: id, codec, bitrate, profile, width, height, pixel_format, frame_rate, opts.
func (VideoProfile) String ¶
func (r VideoProfile) String() string
func (VideoProfile) TimeBase ¶
func (r VideoProfile) TimeBase() *ff.AVRational
func (VideoProfile) Type ¶
func (r VideoProfile) Type() CodecType
func (VideoProfile) UUID ¶
func (r VideoProfile) UUID() uuid.UUID
func (*VideoProfile) UnmarshalJSON ¶ added in v1.9.3
func (r *VideoProfile) UnmarshalJSON(data []byte) error
UnmarshalJSON is required because codec/par/timebase/opts are unexported (see NewVideoProfile) - without it, a client decoding a VideoProfile from JSON would get one with a valid Name but a nil codec, which panics the first time it's used (e.g. writer.WithProfile). Resolves the codec from the decoded Name, exactly as NewVideoProfile does, then rebuilds par from whichever exported fields (Bitrate, Width, ...) were decoded.
type VideoProfileMeta ¶
type VideoProfileMeta struct {
Name string `json:"codec" arg:"" required:""` // "libx264", "libx265", "copy", ...
ProfileMetaVideo
Opts json.RawMessage `json:"options,omitempty"` // Additional codec options
// contains filtered or unexported fields
}
func (VideoProfileMeta) Insert ¶
func (r VideoProfileMeta) Insert(bind *pg.Bind) (string, error)
Insert binds values and returns the insert query for a video profile row.