Documentation ¶
Index ¶
- Constants
- Variables
- func ProbeDuration(ctx context.Context, filename string) (time.Duration, error)
- func Spectrum(ctx context.Context, fs afero.Fs, filename string) (string, error)
- type AudioFormat
- type Buffer
- type BufferReader
- type DecodeError
- type FormatInfo
- type FormatTagsInfo
- type Info
- type LAME
- type MP3Buffer
- type MP3BufferReader
- type PCMBuffer
- type PCMBufferReader
- type ProbeInfo
- type StreamsInfo
Constants ¶
const MP3EncoderDelay = time.Millisecond * 1000.0 / 44100.0 * 576.0
Variables ¶
var ErrBufferFull = errors.New("buffer full")
ErrBufferFull is returned when using MP3Buffer.SetCap and a Write exceeding said cap occurs.
Functions ¶
func ProbeDuration ¶
ProbeDuration attempts to call ffprobe on the file given and returns the duration as returned by it. Requires ffprobe findable in the PATH.
Types ¶
type AudioFormat ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func (*Buffer) Close ¶
Close closes the buffer, any writes will return an error and any readers that are blocked will receive an EOF
func (*Buffer) Reader ¶
func (b *Buffer) Reader() *BufferReader
Reader returns a reader over the data contained in the buffer
func (*Buffer) SetError ¶
SetError sets an error that is returned by all Readers when Read is called. An error set this way does not wait for readers to finish reading data. After setting the error, Close is called.
Passing in a nil error is a no-op
type BufferReader ¶
type BufferReader struct {
// contains filtered or unexported fields
}
BufferReader is an io.Reader on top of a Buffer, multiple readers per Buffer can be created
type DecodeError ¶
DecodeError is returned when a non-zero exit code is returned by the decoder
The ExtraInfo field contains stderr of the decoder process.
func (*DecodeError) Error ¶
func (e *DecodeError) Error() string
type FormatInfo ¶
type FormatInfo struct { BitRate string `json:"bit_rate"` Duration string `json:"duration"` Filename string `json:"filename"` FormatLongName string `json:"format_long_name"` FormatName string `json:"format_name"` NbStreams int `json:"nb_streams"` Size string `json:"size"` StartTime string `json:"start_time"` Tags *FormatTagsInfo `json:"tags"` }
type FormatTagsInfo ¶
type FormatTagsInfo struct { Anime string `json:"ANIME"` Compilation string `json:"COMPILATION,omitempty"` Originaldate string `json:"ORIGINALDATE,omitempty"` R128AlbumGain string `json:"R128_ALBUM_GAIN,omitempty"` R128TrackGain string `json:"R128_TRACK_GAIN,omitempty"` Tbpm string `json:"TBPM,omitempty"` Year string `json:"YEAR,omitempty"` Album string `json:"album"` AlbumArtist string `json:"album_artist,omitempty"` Artist string `json:"artist"` Date string `json:"date,omitempty"` Disc string `json:"disc,omitempty"` Title string `json:"title"` Track string `json:"track,omitempty"` }
type Info ¶
type LAME ¶
type LAME struct { AudioFormat // contains filtered or unexported fields }
func NewLAME ¶
func NewLAME(opt AudioFormat) (*LAME, error)
type MP3Buffer ¶
type MP3Buffer struct { *Buffer // contains filtered or unexported fields }
MP3Buffer is a Buffer that is mp3-aware
func NewMP3Buffer ¶
func NewMP3Buffer() *MP3Buffer
NewMP3Buffer returns a Buffer that is mp3-aware to calculate playback duration and frame validation.
func (*MP3Buffer) BufferBytes ¶
BufferBytes returns unwritten bytes in the internal buffer. return value is only valid until next Write call.
func (*MP3Buffer) Length ¶
Length returns the playback duration of the contents of the buffer. i.e. calling Write increases the duration
func (*MP3Buffer) Reader ¶
func (mb *MP3Buffer) Reader() *MP3BufferReader
Reader returns a reader over the buffer
type MP3BufferReader ¶
type MP3BufferReader struct { *BufferReader // contains filtered or unexported fields }
func (*MP3BufferReader) Length ¶
func (mbr *MP3BufferReader) Length() time.Duration
Length returns the playback duration of the contents of the buffer. i.e. calling Read lowers the duration of the buffer.
func (*MP3BufferReader) Progress ¶
func (mbr *MP3BufferReader) Progress() time.Duration
func (*MP3BufferReader) Sleep ¶
func (mbr *MP3BufferReader) Sleep()
type PCMBuffer ¶
type PCMBuffer struct { AudioFormat *Buffer // contains filtered or unexported fields }
PCMBuffer is a pcm-aware Buffer
func DecodeFile ¶
DecodeFile decodes the audio filepath given and returns a PCMBuffer
func DecodeFileGain ¶
func NewPCMBuffer ¶
func NewPCMBuffer(f AudioFormat) *PCMBuffer
NewPCMBuffer returns a new PCMBuffer with the Format given.
func (*PCMBuffer) Reader ¶
func (pb *PCMBuffer) Reader() *PCMBufferReader
Reader returns a reader over the buffer
type PCMBufferReader ¶
type PCMBufferReader struct { *BufferReader // contains filtered or unexported fields }
PCMBufferReader is a buffer aware of its contents
func (*PCMBufferReader) Length ¶
func (pbr *PCMBufferReader) Length() time.Duration
Length returns the playback duration of the contents of the buffer. i.e. calling Read lowers the duration of the buffer.
func (*PCMBufferReader) Progress ¶
func (pbr *PCMBufferReader) Progress() time.Duration
type ProbeInfo ¶
type ProbeInfo struct { Format *FormatInfo `json:"format,omitempty"` Streams []StreamsInfo `json:"streams,omitempty"` }
type StreamsInfo ¶
type StreamsInfo struct { AvgFrameRate string `json:"avg_frame_rate"` BitRate string `json:"bit_rate,omitempty"` BitsPerSample int `json:"bits_per_sample,omitempty"` Channels int `json:"channels,omitempty"` CodecLongName string `json:"codec_long_name"` CodecName string `json:"codec_name"` CodecTag string `json:"codec_tag"` CodecTagString string `json:"codec_tag_string"` CodecTimeBase string `json:"codec_time_base"` CodecType string `json:"codec_type"` DisplayAspectRatio string `json:"display_aspect_ratio,omitempty"` Duration string `json:"duration"` DurationTs int `json:"duration_ts"` HasBFrames int `json:"has_b_frames,omitempty"` Height int `json:"height,omitempty"` Index int `json:"index"` Level int `json:"level,omitempty"` PixFmt string `json:"pix_fmt,omitempty"` RFrameRate string `json:"r_frame_rate"` SampleAspectRatio string `json:"sample_aspect_ratio,omitempty"` SampleFmt string `json:"sample_fmt,omitempty"` SampleRate string `json:"sample_rate,omitempty"` StartPts int `json:"start_pts"` StartTime string `json:"start_time"` Tags *FormatTagsInfo `json:"tags,omitempty"` TimeBase string `json:"time_base"` Width int `json:"width,omitempty"` }