Documentation
¶
Index ¶
- type AudioData
- type AudioMetadata
- type Decoder
- func (d *Decoder) Close() error
- func (d *Decoder) DecodeBytes(data []byte) (any, error)
- func (d *Decoder) DecodeFile(filename string) (*AudioData, error)
- func (d *Decoder) DecodeReader(reader io.Reader) (any, error)
- func (d *Decoder) DecodeURL(url string, duration time.Duration, streamType string) (*AudioData, error)
- func (d *Decoder) GetConfig() map[string]any
- func (d *Decoder) GetInfo() map[string]any
- func (d *Decoder) GetSupportedFormats() []string
- func (d *Decoder) ProbeURL(ctx context.Context, url string) (*AudioMetadata, error)
- func (d *Decoder) ValidateConfig() error
- type DecoderConfig
- type StreamMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioData ¶
type AudioData struct { PCM []float64 `json:"-"` // Raw PCM data SampleRate int `json:"sample_rate"` Channels int `json:"channels"` Duration time.Duration `json:"duration"` Timestamp time.Time `json:"timestamp"` Metadata *StreamMetadata `json:"metadata,omitempty"` }
AudioData represents decoded audio data
type AudioMetadata ¶
type AudioMetadata struct { SampleRate int `json:"sample_rate"` Channels int `json:"channels"` Codec string `json:"codec"` Duration float64 `json:"duration"` Bitrate int `json:"bitrate"` Format string `json:"format"` }
AudioMetadata holds detected audio properties from FFprobe
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder handles audio decoding using FFmpeg
func NewDecoder ¶
func NewDecoder(config *DecoderConfig) *Decoder
NewDecoder creates a new audio decoder
func NewNormalizingDecoder ¶
func (*Decoder) DecodeBytes ¶
DecodeBytes decodes audio from byte slice Returns AudioData (`any` is for package independence)
func (*Decoder) DecodeFile ¶
DecodeFile decodes an audio file and returns PCM data
func (*Decoder) DecodeReader ¶
DecodeReader decodes audio from an io.Reader Returns `AudioData` (`any` is for package independence)
func (*Decoder) DecodeURL ¶
func (d *Decoder) DecodeURL(url string, duration time.Duration, streamType string) (*AudioData, error)
DecodeURL decodes audio directly from a URL using FFmpeg (for HLS, HTTP streams, etc.)
func (*Decoder) GetSupportedFormats ¶
GetSupportedFormats returns a list of formats supported by this decoder
func (*Decoder) ProbeURL ¶
ProbeURL probes a URL to extract audio metadata without decoding the entire stream
func (*Decoder) ValidateConfig ¶
ValidateConfig validates the decoder configuration
type DecoderConfig ¶
type DecoderConfig struct { TargetSampleRate int `json:"target_sample_rate"` TargetChannels int `json:"target_channels"` OutputFormat string `json:"output_format"` MaxDuration time.Duration `json:"max_duration"` ResampleQuality string `json:"resample_quality"` // "fast", "medium", "high" FFmpegPath string `json:"ffmpeg_path"` // Path to ffmpeg binary FFprobePath string `json:"ffprobe_path"` // Path to ffprobe binary Timeout time.Duration `json:"timeout"` // Timeout for ffmpeg operations // Normalization options EnableNormalization bool `json:"enable_normalization"` NormalizationMethod string `json:"normalization_method"` // "loudnorm", "dynaudnorm", "compand" TargetLUFS float64 `json:"target_lufs"` // -23.0 for broadcast, -16.0 for streaming TargetPeak float64 `json:"target_peak"` // -2.0 LoudnessRange float64 `json:"loudness_range"` // 7.0 typical }
DecoderConfig holds decoder configuration
func ContentOptimizedDecoderConfig ¶
func ContentOptimizedDecoderConfig(contentType string) *DecoderConfig
ContentOptimizedDecoderConfig returns a decoder configuration based on the content type.
The main difference is in the normalization method:
func DefaultDecoderConfig ¶
func DefaultDecoderConfig() *DecoderConfig
DefaultDecoderConfig returns default decoder configuration
type StreamMetadata ¶
type StreamMetadata struct { URL string `json:"url"` Type string `json:"type"` Format string `json:"format"` Bitrate int `json:"bitrate,omitempty"` SampleRate int `json:"sample_rate,omitempty"` Channels int `json:"channels,omitempty"` Codec string `json:"codec,omitempty"` ContentType string `json:"content_type,omitempty"` Title string `json:"title,omitempty"` Artist string `json:"artist,omitempty"` Genre string `json:"genre,omitempty"` Station string `json:"station,omitempty"` Headers map[string]string `json:"headers,omitempty"` Timestamp time.Time `json:"timestamp"` }
StreamMetadata represents metadata about the audio stream/file